From 1588f6210cb41c0a9d9defaa3e0ae71754337cd5 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Wed, 18 Nov 2020 20:15:30 -0500 Subject: Display and query parser layout (#1043) * Update query parser text assignment * Update how padding is used * Hide query parser container by default --- ext/bg/js/query-parser.js | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) (limited to 'ext/bg/js') diff --git a/ext/bg/js/query-parser.js b/ext/bg/js/query-parser.js index 3217316d..16af77b2 100644 --- a/ext/bg/js/query-parser.js +++ b/ext/bg/js/query-parser.js @@ -21,12 +21,13 @@ */ class QueryParser extends EventDispatcher { - constructor({getOptionsContext, progressIndicatorVisible, documentUtil}) { + constructor({getOptionsContext, documentUtil}) { super(); this._getOptionsContext = getOptionsContext; - this._progressIndicatorVisible = progressIndicatorVisible; - this._selectedParser = null; this._documentUtil = documentUtil; + this._text = ''; + this._setTextToken = null; + this._selectedParser = null; this._parseResults = []; this._queryParser = document.querySelector('#query-parser-content'); this._queryParserModeContainer = document.querySelector('#query-parser-mode-container'); @@ -43,6 +44,10 @@ class QueryParser extends EventDispatcher { }); } + get text() { + return this._text; + } + prepare() { this._textScanner.prepare(); this._textScanner.on('searched', this._onSearched.bind(this)); @@ -63,18 +68,18 @@ class QueryParser extends EventDispatcher { } async setText(text) { - const overrideToken = this._progressIndicatorVisible.setOverride(true); - try { - this._setPreview(text); + this._text = text; + this._setPreview(text); - this._parseResults = await api.textParse(text, this._getOptionsContext()); - this._refreshSelectedParser(); + const token = {}; + this._setTextToken = token; + this._parseResults = await api.textParse(text, this._getOptionsContext()); + if (this._setTextToken !== token) { return; } - this._renderParserSelect(); - this._renderParseResult(); - } finally { - this._progressIndicatorVisible.clearOverride(overrideToken); - } + this._refreshSelectedParser(); + + this._renderParserSelect(); + this._renderParseResult(); } // Private -- cgit v1.2.3