Fixed initialization of index for localsearch

This commit is contained in:
squidfunk
2020-03-06 12:02:38 +01:00
parent 184e5f24e2
commit 3a25eb46d4
11 changed files with 21 additions and 20 deletions

View File

@@ -20,15 +20,15 @@
* IN THE SOFTWARE.
*/
import { Observable, Subject, from } from "rxjs"
import { Observable, Subject, asyncScheduler, from } from "rxjs"
import { ajax } from "rxjs/ajax"
import {
map,
observeOn,
pluck,
shareReplay,
switchMap,
take,
tap,
withLatestFrom
} from "rxjs/operators"
@@ -151,11 +151,12 @@ export function setupSearchWorker(
// /* Send index to worker */
// index$
.pipe<SearchSetupMessage>(
map(data => ({
.pipe(
map((data): SearchSetupMessage => ({
type: SearchMessageType.SETUP,
data
}))
})),
observeOn(asyncScheduler) // make sure it runs on the next tick
)
.subscribe(tx$.next.bind(tx$))

View File

@@ -63,7 +63,7 @@ function setupLunrLanguages(config: SearchIndexConfig): void {
/* Load scripts synchronously */
if (scripts.length)
self.importScripts(
importScripts(
`${base}/min/lunr.stemmer.support.min.js`,
...scripts
)
@@ -109,6 +109,6 @@ export function handler(message: SearchMessage): SearchMessage {
* Worker
* ------------------------------------------------------------------------- */
self.addEventListener("message", ev => {
self.postMessage(handler(ev.data))
addEventListener("message", ev => {
postMessage(handler(ev.data))
})