From f23c870b79526b7b3c1143d68c70f0771b4c001b Mon Sep 17 00:00:00 2001 From: Kuuuube <61125188+Kuuuube@users.noreply.github.com> Date: Tue, 17 Dec 2024 10:12:55 -0500 Subject: [PATCH] Fix constant error on firefox mobile from chrome.contextMenus (#1675) * Fix constant error on firefox mobile from chrome.contextMenus * Put if check over whole block * Split out into separate method so it can early return --- ext/js/background/backend.js | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/ext/js/background/backend.js b/ext/js/background/backend.js index 93a4330f5..efb40ed47 100644 --- a/ext/js/background/backend.js +++ b/ext/js/background/backend.js @@ -1330,7 +1330,20 @@ export class Backend { this._clipboardMonitor.stop(); } + this._setupContextMenu(options); + + void this._accessibilityController.update(this._getOptionsFull(false)); + + this._sendMessageAllTabsIgnoreResponse({action: 'applicationOptionsUpdated', params: {source}}); + } + + /** + * @param {import('settings').ProfileOptions} options + */ + _setupContextMenu(options) { try { + if (!chrome.contextMenus) { return; } + if (options.general.enableContextMenuScanSelected) { chrome.contextMenus.create({ id: 'yomitan_lookup', @@ -1348,10 +1361,6 @@ export class Backend { } catch (e) { log.error(e); } - - void this._accessibilityController.update(this._getOptionsFull(false)); - - this._sendMessageAllTabsIgnoreResponse({action: 'applicationOptionsUpdated', params: {source}}); } /**