Merge pull request #2346 from mozilla/order
Fix the tab sorting for custom container ordering - MAC-710
This commit is contained in:
commit
873ba0ab09
4 changed files with 27 additions and 9 deletions
|
@ -19,6 +19,7 @@ module.exports = {
|
|||
"OS": true,
|
||||
"ADDON_UNINSTALL": true,
|
||||
"ADDON_DISABLE": true,
|
||||
"CONTAINER_ORDER_STORAGE_KEY": true,
|
||||
"proxifiedContainers": true,
|
||||
"MozillaVPN": 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 backgroundLogic = {
|
||||
NEW_TAB_PAGES: new Set([
|
||||
"about:startpage",
|
||||
|
@ -168,7 +173,7 @@ const backgroundLogic = {
|
|||
if ("isIsolated" in containerState || remove) {
|
||||
delete containerState.isIsolated;
|
||||
} else {
|
||||
containerState.isIsolated = "locked";
|
||||
containerState.isIsolated = "locked";
|
||||
}
|
||||
return await identityState.storageArea.set(cookieStoreId, containerState);
|
||||
} catch (error) {
|
||||
|
@ -317,19 +322,29 @@ const backgroundLogic = {
|
|||
continue;
|
||||
}
|
||||
|
||||
const userContextId = backgroundLogic.getUserContextIdFromCookieStoreId(tab.cookieStoreId);
|
||||
if (!map.has(userContextId)) {
|
||||
map.set(userContextId, []);
|
||||
if (!map.has(tab.cookieStoreId)) {
|
||||
const userContextId = backgroundLogic.getUserContextIdFromCookieStoreId(tab.cookieStoreId);
|
||||
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.
|
||||
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.
|
||||
sortMap.forEach(tabs => {
|
||||
for (const tab of tabs) {
|
||||
sortMap.forEach(obj => {
|
||||
for (const tab of obj.tabs) {
|
||||
++pos;
|
||||
browser.tabs.move(tab.id, {
|
||||
windowId: windowObj.id,
|
||||
|
|
|
@ -10,7 +10,6 @@ const DEFAULT_ICON = "circle";
|
|||
const NEW_CONTAINER_ID = "new";
|
||||
|
||||
const ONBOARDING_STORAGE_KEY = "onboarding-stage";
|
||||
const CONTAINER_ORDER_STORAGE_KEY = "container-order";
|
||||
const CONTAINER_DRAG_DATA_TYPE = "firefox-container";
|
||||
|
||||
// List of panels
|
||||
|
|
|
@ -2,6 +2,9 @@
|
|||
|
||||
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
|
||||
const Utils = {
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue