Fix the tab sorting for custom container ordering - MAC-710
This commit is contained in:
parent
ba5c58ccbb
commit
d6c6ce6e67
4 changed files with 27 additions and 9 deletions
|
@ -19,6 +19,7 @@ module.exports = {
|
||||||
"OS": true,
|
"OS": true,
|
||||||
"ADDON_UNINSTALL": true,
|
"ADDON_UNINSTALL": true,
|
||||||
"ADDON_DISABLE": true,
|
"ADDON_DISABLE": true,
|
||||||
|
"CONTAINER_ORDER_STORAGE_KEY": true,
|
||||||
"proxifiedContainers": true,
|
"proxifiedContainers": true,
|
||||||
"MozillaVPN": true,
|
"MozillaVPN": true,
|
||||||
"MozillaVPN_Background": true
|
"MozillaVPN_Background": true
|
||||||
|
|
|
@ -1,4 +1,9 @@
|
||||||
|
/* 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/. */
|
||||||
|
|
||||||
const DEFAULT_TAB = "about:newtab";
|
const DEFAULT_TAB = "about:newtab";
|
||||||
|
|
||||||
const backgroundLogic = {
|
const backgroundLogic = {
|
||||||
NEW_TAB_PAGES: new Set([
|
NEW_TAB_PAGES: new Set([
|
||||||
"about:startpage",
|
"about:startpage",
|
||||||
|
@ -168,7 +173,7 @@ const backgroundLogic = {
|
||||||
if ("isIsolated" in containerState || remove) {
|
if ("isIsolated" in containerState || remove) {
|
||||||
delete containerState.isIsolated;
|
delete containerState.isIsolated;
|
||||||
} else {
|
} else {
|
||||||
containerState.isIsolated = "locked";
|
containerState.isIsolated = "locked";
|
||||||
}
|
}
|
||||||
return await identityState.storageArea.set(cookieStoreId, containerState);
|
return await identityState.storageArea.set(cookieStoreId, containerState);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
@ -317,19 +322,29 @@ const backgroundLogic = {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
const userContextId = backgroundLogic.getUserContextIdFromCookieStoreId(tab.cookieStoreId);
|
if (!map.has(tab.cookieStoreId)) {
|
||||||
if (!map.has(userContextId)) {
|
const userContextId = backgroundLogic.getUserContextIdFromCookieStoreId(tab.cookieStoreId);
|
||||||
map.set(userContextId, []);
|
map.set(tab.cookieStoreId, { order: userContextId, tabs: [] });
|
||||||
}
|
}
|
||||||
map.get(userContextId).push(tab);
|
map.get(tab.cookieStoreId).tabs.push(tab);
|
||||||
|
}
|
||||||
|
|
||||||
|
const containerOrderStorage = await browser.storage.local.get([CONTAINER_ORDER_STORAGE_KEY]);
|
||||||
|
const containerOrder =
|
||||||
|
containerOrderStorage && containerOrderStorage[CONTAINER_ORDER_STORAGE_KEY];
|
||||||
|
|
||||||
|
if (containerOrder) {
|
||||||
|
map.forEach((obj, key) => {
|
||||||
|
obj.order = (key in containerOrder) ? containerOrder[key] : -1;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Let's sort the map.
|
// Let's sort the map.
|
||||||
const sortMap = new Map([...map.entries()].sort((a, b) => a[0] > b[0]));
|
const sortMap = new Map([...map.entries()].sort((a, b) => a[1].order > b[1].order));
|
||||||
|
|
||||||
// Let's move tabs.
|
// Let's move tabs.
|
||||||
sortMap.forEach(tabs => {
|
sortMap.forEach(obj => {
|
||||||
for (const tab of tabs) {
|
for (const tab of obj.tabs) {
|
||||||
++pos;
|
++pos;
|
||||||
browser.tabs.move(tab.id, {
|
browser.tabs.move(tab.id, {
|
||||||
windowId: windowObj.id,
|
windowId: windowObj.id,
|
||||||
|
|
|
@ -10,7 +10,6 @@ const DEFAULT_ICON = "circle";
|
||||||
const NEW_CONTAINER_ID = "new";
|
const NEW_CONTAINER_ID = "new";
|
||||||
|
|
||||||
const ONBOARDING_STORAGE_KEY = "onboarding-stage";
|
const ONBOARDING_STORAGE_KEY = "onboarding-stage";
|
||||||
const CONTAINER_ORDER_STORAGE_KEY = "container-order";
|
|
||||||
const CONTAINER_DRAG_DATA_TYPE = "firefox-container";
|
const CONTAINER_DRAG_DATA_TYPE = "firefox-container";
|
||||||
|
|
||||||
// List of panels
|
// List of panels
|
||||||
|
|
|
@ -2,6 +2,9 @@
|
||||||
|
|
||||||
const DEFAULT_FAVICON = "/img/blank-favicon.svg";
|
const DEFAULT_FAVICON = "/img/blank-favicon.svg";
|
||||||
|
|
||||||
|
// eslint-disable-next-line
|
||||||
|
const CONTAINER_ORDER_STORAGE_KEY = "container-order";
|
||||||
|
|
||||||
// TODO use export here instead of globals
|
// TODO use export here instead of globals
|
||||||
const Utils = {
|
const Utils = {
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue