fix: do not load SearchWorker if disableSearch is true (#1191)

Blob URLs may be disabled by CORS (ex: #764) but should not block execution when the disableSearch option is true
This commit is contained in:
Nick Oliver 2020-02-29 21:38:15 -07:00 committed by GitHub
parent c05db38576
commit af415e89e8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -4,8 +4,8 @@ import { OperationModel } from './models';
import Worker from './SearchWorker.worker'; import Worker from './SearchWorker.worker';
function getWorker() {
let worker: new () => Worker; let worker: new () => Worker;
if (IS_BROWSER) { if (IS_BROWSER) {
try { try {
// tslint:disable-next-line // tslint:disable-next-line
@ -16,9 +16,11 @@ if (IS_BROWSER) {
} else { } else {
worker = require('./SearchWorker.worker').default; worker = require('./SearchWorker.worker').default;
} }
return new worker();
}
export class SearchStore<T> { export class SearchStore<T> {
searchWorker = new worker(); searchWorker = getWorker();
indexItems(groups: Array<IMenuItem | OperationModel>) { indexItems(groups: Array<IMenuItem | OperationModel>) {
const recurse = items => { const recurse = items => {