diff --git a/src/js/background/backgroundLogic.js b/src/js/background/backgroundLogic.js index a5b0e18..d21cf33 100644 --- a/src/js/background/backgroundLogic.js +++ b/src/js/background/backgroundLogic.js @@ -35,10 +35,39 @@ const backgroundLogic = { browser.permissions.onRemoved.addListener(permissions => this.resetPermissions(permissions)); // Update Translation in Manifest - browser.runtime.onInstalled.addListener(this.updateTranslationInManifest); + browser.runtime.onInstalled.addListener((details) => { + this.updateTranslationInManifest(); + this._undoDefault820SortTabsKeyboardShortcut(details); + }); browser.runtime.onStartup.addListener(this.updateTranslationInManifest); }, + /** + * One-time migration after updating from v8.2.0: + * Unset the default keyboard shortcut (Ctrl+Comma) for the `sort_tabs` + * command if it was set in v8.2.0 of this addon. If the user remapped + * a different shortcut manually, retain their shortcut. Users who used + * the default keyboard shortcut will need to manually set a shortcut. + * See https://support.mozilla.org/en-US/kb/manage-extension-shortcuts-firefox + * + * @param {{reason: runtime.OnInstalledReason, previousVersion?: string}} details + */ + async _undoDefault820SortTabsKeyboardShortcut(details) { + if (details.reason === "update" && details.previousVersion === "8.2.0") { + const commands = await browser.commands.getAll(); + const sortTabsCommand = commands.find(command => command.name === "sort_tabs"); + if (sortTabsCommand) { + const previouslySuggestedKeys = [ + "Ctrl+Comma", // "default" + "MacCtrl+Comma", // "mac" + ]; + if (previouslySuggestedKeys.includes(sortTabsCommand.shortcut)) { + browser.commands.reset("sort_tabs"); + } + } + } + }, + updateTranslationInManifest() { for (let index = 0; index < 10; index++) { const ajustedIndex = index + 1; // We want to start from 1 instead of 0 in the UI. diff --git a/src/manifest.json b/src/manifest.json index daebff1..30e3be6 100644 --- a/src/manifest.json +++ b/src/manifest.json @@ -45,10 +45,6 @@ "description": "__MSG_openContainerPanel__" }, "sort_tabs": { - "suggested_key": { - "default": "Ctrl+Comma", - "mac": "MacCtrl+Comma" - }, "description": "__MSG_sortTabsByContainer__" }, "open_container_0": {