mirror of
https://github.com/squidfunk/mkdocs-material.git
synced 2026-07-29 09:12:35 -04:00
Added note when search is initializing
This commit is contained in:
@@ -25,7 +25,6 @@ import {
|
||||
filter,
|
||||
map,
|
||||
mapTo,
|
||||
pluck,
|
||||
sample,
|
||||
startWith,
|
||||
switchMap,
|
||||
@@ -109,8 +108,7 @@ export function mountSearch(
|
||||
.pipe(
|
||||
filter(isSearchQueryMessage),
|
||||
sample(status$),
|
||||
take(1),
|
||||
filter(({ data }) => data.length > 0)
|
||||
take(1)
|
||||
)
|
||||
.subscribe(tx$.next.bind(tx$))
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ import {
|
||||
distinctUntilChanged,
|
||||
filter,
|
||||
map,
|
||||
mapTo,
|
||||
pluck,
|
||||
startWith,
|
||||
switchMap
|
||||
@@ -35,6 +36,7 @@ import { WorkerHandler, watchElementOffset } from "browser"
|
||||
import {
|
||||
SearchMessage,
|
||||
SearchResult,
|
||||
isSearchReadyMessage,
|
||||
isSearchResultMessage
|
||||
} from "integrations"
|
||||
|
||||
@@ -71,6 +73,13 @@ export function mountSearchResult(
|
||||
switchMap(el => {
|
||||
const container = el.parentElement!
|
||||
|
||||
/* Compute if search is ready */
|
||||
const ready$ = rx$
|
||||
.pipe(
|
||||
filter(isSearchReadyMessage),
|
||||
mapTo(true)
|
||||
)
|
||||
|
||||
/* Compute whether there are more search results to fetch */
|
||||
const fetch$ = watchElementOffset(container)
|
||||
.pipe(
|
||||
@@ -86,7 +95,7 @@ export function mountSearchResult(
|
||||
.pipe(
|
||||
filter(isSearchResultMessage),
|
||||
pluck("data"),
|
||||
applySearchResult(el, { query$, fetch$ }),
|
||||
applySearchResult(el, { query$, ready$, fetch$ }),
|
||||
startWith([])
|
||||
)
|
||||
})
|
||||
|
||||
@@ -57,6 +57,7 @@ import {
|
||||
*/
|
||||
interface ApplyOptions {
|
||||
query$: Observable<SearchQuery> /* Search query observable */
|
||||
ready$: Observable<boolean> /* Search ready observable */
|
||||
fetch$: Observable<boolean> /* Result fetch observable */
|
||||
}
|
||||
|
||||
@@ -77,14 +78,14 @@ interface ApplyOptions {
|
||||
* @return Operator function
|
||||
*/
|
||||
export function applySearchResult(
|
||||
el: HTMLElement, { query$, fetch$ }: ApplyOptions
|
||||
el: HTMLElement, { query$, ready$, fetch$ }: ApplyOptions
|
||||
): MonoTypeOperatorFunction<SearchResult[]> {
|
||||
const list = getElementOrThrow(".md-search-result__list", el)
|
||||
const meta = getElementOrThrow(".md-search-result__meta", el)
|
||||
return pipe(
|
||||
|
||||
/* Apply search result metadata */
|
||||
withLatestFrom(query$),
|
||||
withLatestFrom(query$, ready$),
|
||||
map(([result, query]) => {
|
||||
if (query.value) {
|
||||
setSearchResultMeta(meta, result.length)
|
||||
|
||||
Reference in New Issue
Block a user