Fix command handling
This commit is contained in:
parent
b1f72905cf
commit
69556533e1
@ -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}) {
|
||||
|
Loading…
Reference in New Issue
Block a user