summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorsiikamiika <siikamiika@users.noreply.github.com>2019-11-13 13:09:23 +0200
committersiikamiika <siikamiika@users.noreply.github.com>2019-11-23 17:50:46 +0200
commit707b039927f27443f9e32cffe342e7f778dff955 (patch)
tree25b5efeb14a7f3b92aa34fd923a1f58fdeabf36f /ext
parent0d6e0edc31d4ceac58b886e238b77f0143a5c3ec (diff)
store local copy of selected parser
Options don't update early enough even after awaiting
Diffstat (limited to 'ext')
-rw-r--r--ext/bg/js/search-query-parser.js14
1 files changed, 10 insertions, 4 deletions
diff --git a/ext/bg/js/search-query-parser.js b/ext/bg/js/search-query-parser.js
index 15c394fe..71ebb389 100644
--- a/ext/bg/js/search-query-parser.js
+++ b/ext/bg/js/search-query-parser.js
@@ -24,6 +24,7 @@ class QueryParser {
this.clickScanPrevent = false;
this.parseResults = [];
+ this.selectedParser = null;
this.queryParser = document.querySelector('#query-parser');
this.queryParserSelect = document.querySelector('#query-parser-select');
@@ -85,14 +86,15 @@ class QueryParser {
})();
}
- onParserChange(e) {
+ async onParserChange(e) {
const selectedParser = e.target.value;
+ this.selectedParser = selectedParser;
apiOptionsSet({parsing: {selectedParser}}, this.search.getOptionsContext());
this.renderParseResult(this.getParseResult());
}
getParseResult() {
- return this.parseResults.find(r => r.id === this.search.options.parsing.selectedParser);
+ return this.parseResults.find(r => r.id === this.selectedParser);
}
async setText(text) {
@@ -102,8 +104,12 @@ class QueryParser {
this.parseResults = await this.parseText(text);
if (this.parseResults.length > 0) {
- if (this.search.options.parsing.selectedParser === null || !this.getParseResult()) {
+ if (this.selectedParser === null) {
+ this.selectedParser = this.search.options.parsing.selectedParser;
+ }
+ if (this.selectedParser === null || !this.getParseResult()) {
const selectedParser = this.parseResults[0].id;
+ this.selectedParser = selectedParser;
apiOptionsSet({parsing: {selectedParser}}, this.search.getOptionsContext());
}
}
@@ -162,7 +168,7 @@ class QueryParser {
const option = document.createElement('option');
option.value = parseResult.id;
option.innerText = parseResult.name;
- option.defaultSelected = this.search.options.parsing.selectedParser === parseResult.id;
+ option.defaultSelected = this.selectedParser === parseResult.id;
select.appendChild(option);
}
select.addEventListener('change', this.onParserChange.bind(this));