Skip to content

Commit

Permalink
fix: do not load SearchWorker if disableSearch is true (#1191)
Browse files Browse the repository at this point in the history
Blob URLs may be disabled by CORS (ex: #764) but should not block execution when the disableSearch option is true
  • Loading branch information
PixnBits authored Mar 1, 2020
1 parent c05db38 commit af415e8
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions src/services/SearchStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand Down

0 comments on commit af415e8

Please sign in to comment.