summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2019-12-12 19:59:43 -0500
committertoasted-nutbread <toasted-nutbread@users.noreply.github.com>2019-12-13 23:11:56 -0500
commit69556533e172f32915f84413130ff2630804f5ec (patch)
tree7338d6017f8eeaecd7f0c9c2662b7e0b2e8da549
parentb1f72905cf70a9ddb94f033cae0cb7cc03468e21 (diff)
Fix command handling
-rw-r--r--ext/bg/js/backend.js19
1 files changed, 10 insertions, 9 deletions
diff --git a/ext/bg/js/backend.js b/ext/bg/js/backend.js
index 877161c7..fb680304 100644
--- a/ext/bg/js/backend.js
+++ b/ext/bg/js/backend.js
@@ -42,7 +42,7 @@ class Backend {
this.onOptionsUpdated('background');
if (chrome.commands !== null && typeof chrome.commands === 'object') {
- chrome.commands.onCommand.addListener(this.onCommand.bind(this));
+ chrome.commands.onCommand.addListener((command) => this._runCommand(command));
}
chrome.runtime.onMessage.addListener(this.onMessage.bind(this));
@@ -67,10 +67,6 @@ class Backend {
});
}
- onCommand(command) {
- apiCommandExec(command);
- }
-
onMessage({action, params}, sender, callback) {
const handler = Backend._messageHandlers.get(action);
if (typeof handler !== 'function') { return false; }
@@ -184,6 +180,14 @@ class Backend {
// NOP
}
+ _runCommand(command, params) {
+ const handler = Backend._commandHandlers.get(command);
+ if (typeof handler !== 'function') { return false; }
+
+ handler(this, params);
+ return true;
+ }
+
// Message handlers
_onApiOptionsGet({optionsContext}) {
@@ -398,10 +402,7 @@ class Backend {
}
async _onApiCommandExec({command, params}) {
- const handler = Backend._commandHandlers.get(command);
- if (typeof handler !== 'function') { return false; }
-
- handler(this, params);
+ return this._runCommand(command, params);
}
async _onApiAudioGetUrl({definition, source, optionsContext}) {