address feedback 02

This commit is contained in:
Anton Dudakov
2026-02-26 22:01:54 +04:00
parent eda79aaf05
commit 2f6596259b
+18 -19
View File
@@ -12,35 +12,33 @@ const backgroundLogic = {
"about:home", "about:home",
"about:blank" "about:blank"
]), ]),
// Use shared constants for counts NUMBER_OF_KEYBOARD_SHORTCUTS: MAC_CONSTANTS.NUMBER_OF_KEYBOARD_SHORTCUTS,
// NOTE: Keep in sync with MAC_CONSTANTS.NUMBER_OF_KEYBOARD_SHORTCUTS
unhideQueue: [], unhideQueue: [],
init() { init() {
browser.commands.onCommand.addListener(async function (command) { browser.commands.onCommand.addListener(async function (command) {
if (command === "sort_tabs") { if (command === "sort_tabs") {
backgroundLogic.sortTabs(); backgroundLogic.sortTabs();
} else if (command.startsWith(MAC_CONSTANTS.OPEN_CONTAINER_PREFIX)) { return;
for (let i = 0; i < MAC_CONSTANTS.NUMBER_OF_KEYBOARD_SHORTCUTS; i++) { }
for (let i=0; i < backgroundLogic.NUMBER_OF_KEYBOARD_SHORTCUTS; i++) {
const key = MAC_CONSTANTS.OPEN_CONTAINER_PREFIX + i; const key = MAC_CONSTANTS.OPEN_CONTAINER_PREFIX + i;
const reopenKey = MAC_CONSTANTS.REOPEN_IN_CONTAINER_PREFIX + i;
const cookieStoreId = identityState.keyboardShortcut[key]; const cookieStoreId = identityState.keyboardShortcut[key];
if (cookieStoreId === "none") {
continue;
}
if (command === key) { if (command === key) {
if (cookieStoreId !== "none") {
browser.tabs.create({cookieStoreId}); browser.tabs.create({cookieStoreId});
return;
} }
break;
} if (command === reopenKey) {
}
} else if (command.startsWith(MAC_CONSTANTS.REOPEN_IN_CONTAINER_PREFIX)) {
for (let i = 0; i < MAC_CONSTANTS.NUMBER_OF_KEYBOARD_SHORTCUTS; i++) {
const key = MAC_CONSTANTS.REOPEN_IN_CONTAINER_PREFIX + i;
const cookieStoreId = identityState.keyboardShortcut[key];
if (command === key) {
if (cookieStoreId !== "none") {
backgroundLogic.reopenInContainer(cookieStoreId); backgroundLogic.reopenInContainer(cookieStoreId);
} return;
break;
}
} }
} }
}); });
@@ -84,7 +82,7 @@ const backgroundLogic = {
}, },
async reopenInContainer(cookieStoreId) { async reopenInContainer(cookieStoreId) {
const currentTab = await browser.tabs.query({active: true, currentWindow: true}); const currentTab = await browser.tabs.query({ active: true, currentWindow: true })
if (currentTab.length > 0) { if (currentTab.length > 0) {
const tab = currentTab[0]; const tab = currentTab[0];
@@ -327,7 +325,8 @@ const backgroundLogic = {
}); });
} else { } else {
// As we get a blank tab here we will need to await the tabs creation // As we get a blank tab here we will need to await the tabs creation
newWindowObj = await browser.windows.create({}); newWindowObj = await browser.windows.create({
});
hiddenDefaultTabToClose = true; hiddenDefaultTabToClose = true;
} }