@@ -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.
0 commit comments