diff --git a/src/js/background/backgroundLogic.js b/src/js/background/backgroundLogic.js index acc26dc..29e7825 100644 --- a/src/js/background/backgroundLogic.js +++ b/src/js/background/backgroundLogic.js @@ -1,8 +1,9 @@ -/* global MAC_CONSTANTS */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. */ +/* global MAC_CONSTANTS */ + const DEFAULT_TAB = "about:newtab"; const backgroundLogic = { diff --git a/src/js/background/constants.js b/src/js/background/constants.js index 27d5583..f7f547c 100644 --- a/src/js/background/constants.js +++ b/src/js/background/constants.js @@ -1,6 +1,10 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. */ + // Shared constants for background scripts window.MAC_CONSTANTS = { OPEN_CONTAINER_PREFIX: "open_container_", REOPEN_IN_CONTAINER_PREFIX: "reopen_in_container_", NUMBER_OF_KEYBOARD_SHORTCUTS: 10, -}; \ No newline at end of file +}; diff --git a/src/js/background/identityState.js b/src/js/background/identityState.js index 1202c2a..8d3d52f 100644 --- a/src/js/background/identityState.js +++ b/src/js/background/identityState.js @@ -1,3 +1,7 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. */ + /* global MAC_CONSTANTS */ window.identityState = { keyboardShortcut: {}, @@ -54,20 +58,19 @@ window.identityState = { for (let i=0; i < MAC_CONSTANTS.NUMBER_OF_KEYBOARD_SHORTCUTS; i++) { const openKey = MAC_CONSTANTS.OPEN_CONTAINER_PREFIX + i; const reopenKey = MAC_CONSTANTS.REOPEN_IN_CONTAINER_PREFIX + i; - const storageObject = await this.area.get(openKey); - if (storageObject[openKey]){ - identityState.keyboardShortcut[openKey] = storageObject[openKey]; - identityState.keyboardShortcut[reopenKey] = storageObject[openKey]; - continue; + for (const key of [openKey, reopenKey]) { + const storageObject = await this.area.get(key); + + if (storageObject[key]){ + identityState.keyboardShortcut[key] = storageObject[key]; + } else if (identities[i]) { + identityState.keyboardShortcut[key] = identities[i].cookieStoreId; + } else { + identityState.keyboardShortcut[key] = "none"; + } } - if (identities[i]) { - identityState.keyboardShortcut[openKey] = identities[i].cookieStoreId; - identityState.keyboardShortcut[reopenKey] = identities[i].cookieStoreId; - continue; - } - identityState.keyboardShortcut[openKey] = "none"; - identityState.keyboardShortcut[reopenKey] = "none"; + } return identityState.keyboardShortcut; }, diff --git a/test/features/reopen-shortcuts.test.js b/test/features/reopen-shortcuts.test.js index ac3781c..c9d0b9f 100644 --- a/test/features/reopen-shortcuts.test.js +++ b/test/features/reopen-shortcuts.test.js @@ -41,4 +41,4 @@ describe("Reopen Shortcuts Feature", function () { this.webExt.background.browser.tabs.remove.should.not.have.been.called; }); }); -}); \ No newline at end of file +});