Skip to content

Commit 9434147

Browse files
authored
Merge pull request #2758 from apostrophest/remove-sort-tabs-suggested-key
Remove suggested key for `sort_tabs`
2 parents d82341c + f1a24ed commit 9434147

2 files changed

Lines changed: 30 additions & 5 deletions

File tree

src/js/background/backgroundLogic.js

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,39 @@ const backgroundLogic = {
3535
browser.permissions.onRemoved.addListener(permissions => this.resetPermissions(permissions));
3636

3737
// Update Translation in Manifest
38-
browser.runtime.onInstalled.addListener(this.updateTranslationInManifest);
38+
browser.runtime.onInstalled.addListener((details) => {
39+
this.updateTranslationInManifest();
40+
this._undoDefault820SortTabsKeyboardShortcut(details);
41+
});
3942
browser.runtime.onStartup.addListener(this.updateTranslationInManifest);
4043
},
4144

45+
/**
46+
* One-time migration after updating from v8.2.0:
47+
* Unset the default keyboard shortcut (Ctrl+Comma) for the `sort_tabs`
48+
* command if it was set in v8.2.0 of this addon. If the user remapped
49+
* a different shortcut manually, retain their shortcut. Users who used
50+
* the default keyboard shortcut will need to manually set a shortcut.
51+
* See https://support.mozilla.org/en-US/kb/manage-extension-shortcuts-firefox
52+
*
53+
* @param {{reason: runtime.OnInstalledReason, previousVersion?: string}} details
54+
*/
55+
async _undoDefault820SortTabsKeyboardShortcut(details) {
56+
if (details.reason === "update" && details.previousVersion === "8.2.0") {
57+
const commands = await browser.commands.getAll();
58+
const sortTabsCommand = commands.find(command => command.name === "sort_tabs");
59+
if (sortTabsCommand) {
60+
const previouslySuggestedKeys = [
61+
"Ctrl+Comma", // "default"
62+
"MacCtrl+Comma", // "mac"
63+
];
64+
if (previouslySuggestedKeys.includes(sortTabsCommand.shortcut)) {
65+
browser.commands.reset("sort_tabs");
66+
}
67+
}
68+
}
69+
},
70+
4271
updateTranslationInManifest() {
4372
for (let index = 0; index < 10; index++) {
4473
const ajustedIndex = index + 1; // We want to start from 1 instead of 0 in the UI.

src/manifest.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,6 @@
4545
"description": "__MSG_openContainerPanel__"
4646
},
4747
"sort_tabs": {
48-
"suggested_key": {
49-
"default": "Ctrl+Comma",
50-
"mac": "MacCtrl+Comma"
51-
},
5248
"description": "__MSG_sortTabsByContainer__"
5349
},
5450
"open_container_0": {

0 commit comments

Comments
 (0)