aboutsummaryrefslogtreecommitdiff
path: root/ext/bg/js/search-query-parser.js
diff options
context:
space:
mode:
authorsiikamiika <siikamiika@users.noreply.github.com>2020-03-13 23:23:08 +0200
committersiikamiika <siikamiika@users.noreply.github.com>2020-03-21 22:13:07 +0200
commit962c2a381f3dace4d97fd0625504ec841e378354 (patch)
tree92ea4bee6a3a70f61965e98ca143b2a18cfcdad3 /ext/bg/js/search-query-parser.js
parent647769f2baae338f201690f21c4bf8983bcb10b0 (diff)
apply all options on profile change
Diffstat (limited to 'ext/bg/js/search-query-parser.js')
-rw-r--r--ext/bg/js/search-query-parser.js17
1 files changed, 6 insertions, 11 deletions
diff --git a/ext/bg/js/search-query-parser.js b/ext/bg/js/search-query-parser.js
index 06316ce2..6e18073b 100644
--- a/ext/bg/js/search-query-parser.js
+++ b/ext/bg/js/search-query-parser.js
@@ -28,11 +28,10 @@
class QueryParser extends TextScanner {
constructor(search) {
- super(document.querySelector('#query-parser-content'), [], [], []);
+ super(document.querySelector('#query-parser-content'), [], []);
this.search = search;
this.parseResults = [];
- this.selectedParser = null;
this.queryParser = document.querySelector('#query-parser-content');
this.queryParserSelect = document.querySelector('#query-parser-select-container');
@@ -79,9 +78,7 @@ class QueryParser extends TextScanner {
onParserChange(e) {
const selectedParser = e.target.value;
- this.selectedParser = selectedParser;
apiOptionsSet({parsing: {selectedParser}}, this.search.getOptionsContext());
- this.renderParseResult();
}
getMouseEventListeners() {
@@ -112,19 +109,16 @@ class QueryParser extends TextScanner {
refreshSelectedParser() {
if (this.parseResults.length > 0) {
- if (this.selectedParser === null) {
- this.selectedParser = this.search.options.parsing.selectedParser;
- }
- if (this.selectedParser === null || !this.getParseResult()) {
+ if (!this.getParseResult()) {
const selectedParser = this.parseResults[0].id;
- this.selectedParser = selectedParser;
apiOptionsSet({parsing: {selectedParser}}, this.search.getOptionsContext());
}
}
}
getParseResult() {
- return this.parseResults.find((r) => r.id === this.selectedParser);
+ const {selectedParser} = this.options.parsing;
+ return this.parseResults.find((r) => r.id === selectedParser);
}
async setText(text) {
@@ -176,7 +170,8 @@ class QueryParser extends TextScanner {
renderParserSelect() {
this.queryParserSelect.textContent = '';
if (this.parseResults.length > 1) {
- const select = this.queryParserGenerator.createParserSelect(this.parseResults, this.selectedParser);
+ const {selectedParser} = this.options.parsing;
+ const select = this.queryParserGenerator.createParserSelect(this.parseResults, selectedParser);
select.addEventListener('change', this.onParserChange.bind(this));
this.queryParserSelect.appendChild(select);
}