Fixed race condition ehen displaying search result metadata

This commit is contained in:
squidfunk
2021-10-06 14:57:27 +02:00
parent 905c8b77c6
commit 8779d78a13
6 changed files with 17 additions and 22 deletions

View File

@@ -225,7 +225,7 @@
</script> </script>
{% endblock %} {% endblock %}
{% block scripts %} {% block scripts %}
<script src="{{ 'assets/javascripts/bundle.39a44d95.min.js' | url }}"></script> <script src="{{ 'assets/javascripts/bundle.bc35569b.min.js' | url }}"></script>
{% for path in config["extra_javascript"] %} {% for path in config["extra_javascript"] %}
<script src="{{ path | url }}"></script> <script src="{{ path | url }}"></script>
{% endfor %} {% endfor %}

View File

@@ -107,12 +107,8 @@ export function mountSearch(
tx$ tx$
.pipe( .pipe(
filter(isSearchQueryMessage), filter(isSearchQueryMessage),
sample(rx$ sample(rx$.pipe(filter(isSearchReadyMessage))),
.pipe( take(1)
filter(isSearchReadyMessage),
take(1)
)
)
) )
.subscribe(tx$.next.bind(tx$)) .subscribe(tx$.next.bind(tx$))

View File

@@ -33,6 +33,7 @@ import {
finalize, finalize,
map, map,
observeOn, observeOn,
skipUntil,
switchMap, switchMap,
take, take,
tap, tap,
@@ -102,20 +103,18 @@ export function mountSearchResult(
const list = getElementOrThrow(":scope > :last-child", el) const list = getElementOrThrow(":scope > :last-child", el)
/* Update search result metadata when ready */ /* Update search result metadata when ready */
rx$ const ready$ = rx$
.pipe( .pipe(
filter(isSearchReadyMessage), filter(isSearchReadyMessage),
take(1) take(1)
) )
.subscribe(() => {
resetSearchResultMeta(meta)
})
/* Update search result metadata */ /* Update search result metadata */
internal$ internal$
.pipe( .pipe(
observeOn(animationFrameScheduler), observeOn(animationFrameScheduler),
withLatestFrom(query$) withLatestFrom(query$),
skipUntil(ready$)
) )
.subscribe(([{ items }, { value }]) => { .subscribe(([{ items }, { value }]) => {
if (value) if (value)

View File

@@ -127,10 +127,10 @@ export function setupSearchWorker(
/* Set up search index */ /* Set up search index */
from(index) from(index)
.pipe( .pipe(
map<SearchIndex, SearchSetupMessage>(data => ({ map(data => ({
type: SearchMessageType.SETUP, type: SearchMessageType.SETUP,
data: setupSearchIndex(data) data: setupSearchIndex(data)
})) } as SearchSetupMessage))
) )
.subscribe(tx$.next.bind(tx$)) .subscribe(tx$.next.bind(tx$))