extracted reopenInContainer function which made it possible to remove

async from the `init()`
This commit is contained in:
Anton Dudakov 2025-07-15 08:42:37 +02:00 committed by Anton Dudakov
parent 6a2c50a89f
commit 81ee998a57
2 changed files with 19 additions and 16 deletions

@ -1 +1 @@
Subproject commit bdaa01291b7367a5e815470fd263ea36c862fe32
Subproject commit 4f5188f3ba55916db3d74345abbbe651e2e8be78

View file

@ -14,7 +14,7 @@ const backgroundLogic = {
NUMBER_OF_KEYBOARD_SHORTCUTS: 10,
unhideQueue: [],
async init() {
init() {
browser.commands.onCommand.addListener(async function (command) {
if (command === "sort_tabs") {
backgroundLogic.sortTabs();
@ -36,19 +36,7 @@ const backgroundLogic = {
}
if (command === reopenKey) {
const currentTab = await browser.tabs.query({active: true, currentWindow: true});
if (currentTab.length > 0) {
const tab = currentTab[0];
await browser.tabs.create({
url: tab.url,
cookieStoreId: cookieStoreId,
index: tab.index + 1,
active: tab.active
});
await browser.tabs.remove(tab.id);
}
backgroundLogic.reopenInContainer(cookieStoreId);
return;
}
}
@ -88,12 +76,27 @@ const backgroundLogic = {
browser.commands.reset("sort_tabs");
}
}
async reopenInContainer(cookieStoreId) {
const currentTab = await browser.tabs.query({ active: true, currentWindow: true })
if (currentTab.length > 0) {
const tab = currentTab[0];
browser.tabs.create({
url: tab.url,
cookieStoreId: cookieStoreId,
index: tab.index + 1,
active: tab.active
});
browser.tabs.remove(tab.id);
}
},
updateTranslationInManifest() {
for (let index = 0; index < 10; index++) {
const adjustedIndex = index + 1;
const adjustedIndex = index + 1; // We want to start from 1 instead of 0 in the UI.
browser.commands.update({
name: `open_container_${index}`,
description: browser.i18n.getMessage("containerShortcut", `${adjustedIndex}`)