Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 30 additions & 1 deletion src/js/background/backgroundLogic.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 0 additions & 4 deletions src/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,6 @@
"description": "__MSG_openContainerPanel__"
},
"sort_tabs": {
"suggested_key": {
"default": "Ctrl+Comma",
"mac": "MacCtrl+Comma"
},
"description": "__MSG_sortTabsByContainer__"
},
"open_container_0": {
Expand Down
Loading