diff --git a/chatto/src/main/javascript/ts/src/service/FuseSearchService.ts b/chatto/src/main/javascript/ts/src/service/FuseSearchService.ts index c367d20..00b877a 100644 --- a/chatto/src/main/javascript/ts/src/service/FuseSearchService.ts +++ b/chatto/src/main/javascript/ts/src/service/FuseSearchService.ts @@ -3,7 +3,7 @@ import { SearchService } from "./SearchService"; import Fuse = require('fuse.js'); export class FuseSearchService implements SearchService { - // private readonly _fuse: Fuse; + private readonly _fuse: Fuse; private readonly _params: Fuse.FuseOptions; constructor(keys: string[], params: Fuse.FuseOptions = { @@ -19,13 +19,14 @@ export class FuseSearchService implements SearchService { }) { this._params = params; this._params.keys = keys; - // this._fuse = new Fuse(list, this._params); + this._fuse = new Fuse([], this._params); } - search(list: T[], searchTerm: string): T[] { - const fuse = new Fuse>(list, this._params); + search(list: T[], searchTerm: string): T[] { + // const fuse = new Fuse>(list, this._params); + this._fuse.setCollection(list); // fuse.search(searchTerm); - return fuse.search(searchTerm) as T[]; + return this._fuse.search(searchTerm) as T[]; } } \ No newline at end of file diff --git a/chatto/src/main/javascript/ts/src/service/SearchService.ts b/chatto/src/main/javascript/ts/src/service/SearchService.ts index 69cbf7e..0aea13b 100644 --- a/chatto/src/main/javascript/ts/src/service/SearchService.ts +++ b/chatto/src/main/javascript/ts/src/service/SearchService.ts @@ -1,3 +1,3 @@ export interface SearchService { - search(list: T[], pattern: string): T[]; + search(list: T[], pattern: string): T[]; } \ No newline at end of file