From 91bc31d7582fb54908433cd8b6e46b5a0be4e9b3 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Sat, 7 Sep 2019 11:21:06 -0400 Subject: Change how options updates are handled on the frontend Only an 'optionsUpdate' signal is now sent to the frontend with empty data. The frontend then responds by performing apiOptionsGet to update the options. This makes it so that there is only a single function which is responsible for requesting options from the backend. --- ext/fg/js/frontend.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'ext/fg') diff --git a/ext/fg/js/frontend.js b/ext/fg/js/frontend.js index 52620933..83e0cef1 100644 --- a/ext/fg/js/frontend.js +++ b/ext/fg/js/frontend.js @@ -261,11 +261,8 @@ class Frontend { onBgMessage({action, params}, sender, callback) { const handlers = { - optionsSet: ({options}) => { - this.options = options; - if (!this.options.enable) { - this.searchClear(); - } + optionsUpdate: () => { + this.updateOptions(); }, popupSetVisible: ({visible}) => { @@ -284,6 +281,13 @@ class Frontend { console.log(error); } + async updateOptions() { + this.options = await apiOptionsGet(); + if (!this.options.enable) { + this.searchClear(); + } + } + popupTimerSet(callback) { this.popupTimerClear(); this.popupTimer = window.setTimeout(callback, this.options.scanning.delay); -- cgit v1.2.3