From 9c98c631afde843f8b5ed4c54fc1f4ff0ec3a00a Mon Sep 17 00:00:00 2001 From: siikamiika Date: Mon, 10 Feb 2020 22:09:23 +0200 Subject: fix async issues --- ext/bg/js/search-query-parser-generator.js | 3 +-- ext/bg/js/search-query-parser.js | 4 ++++ ext/bg/js/search.js | 2 ++ 3 files changed, 7 insertions(+), 2 deletions(-) (limited to 'ext/bg/js') diff --git a/ext/bg/js/search-query-parser-generator.js b/ext/bg/js/search-query-parser-generator.js index 67a1ccad..8d71890b 100644 --- a/ext/bg/js/search-query-parser-generator.js +++ b/ext/bg/js/search-query-parser-generator.js @@ -20,10 +20,9 @@ class QueryParserGenerator { constructor() { this._templateHandler = null; - this._initialize(); } - async _initialize() { + async prepare() { const html = await apiGetQueryParserTemplatesHtml(); this._templateHandler = new TemplateHandler(html); } diff --git a/ext/bg/js/search-query-parser.js b/ext/bg/js/search-query-parser.js index 3a93c7e7..f648fdd4 100644 --- a/ext/bg/js/search-query-parser.js +++ b/ext/bg/js/search-query-parser.js @@ -31,6 +31,10 @@ class QueryParser extends TextScanner { this.queryParserGenerator = new QueryParserGenerator(); } + async prepare() { + await this.queryParserGenerator.prepare(); + } + onError(error) { logError(error, false); } diff --git a/ext/bg/js/search.js b/ext/bg/js/search.js index 4da27513..6641255f 100644 --- a/ext/bg/js/search.js +++ b/ext/bg/js/search.js @@ -49,6 +49,8 @@ class DisplaySearch extends Display { try { await this.initialize(); + await this.queryParser.prepare(); + const {queryParams: {query='', mode=''}} = parseUrl(window.location.href); if (this.search !== null) { -- cgit v1.2.3