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,21 +4,23 @@ import { OperationModel } from './models';
import Worker from './SearchWorker.worker';
let worker: new () => Worker;
if (IS_BROWSER) {
try {
// tslint:disable-next-line
worker = require('workerize-loader?inline&fallback=false!./SearchWorker.worker');
} catch (e) {
function getWorker() {
let worker: new () => Worker;
if (IS_BROWSER) {
try {
// tslint:disable-next-line
worker = require('workerize-loader?inline&fallback=false!./SearchWorker.worker');
} catch (e) {
worker = require('./SearchWorker.worker').default;
}
} else {
worker = require('./SearchWorker.worker').default;
}
} else {
worker = require('./SearchWorker.worker').default;
return new worker();
}
export class SearchStore<T> {
searchWorker = new worker();
searchWorker = getWorker();
indexItems(groups: Array<IMenuItem | OperationModel>) {
const recurse = items => {