Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Migrate pinned tabs from older Zen versions #2716

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 14 additions & 8 deletions src/browser/base/zen-components/ZenPinnedTabManager.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,6 @@
_initializePinnedTabs() {
const pins = this._pinsCache;
if (!pins?.length) {
// If there are no pins, we should remove any existing pinned tabs
for (let tab of gBrowser.tabs) {
if (tab.pinned && !tab.getAttribute("zen-pin-id")) {
gBrowser.removeTab(tab);
}
}
return;
}

Expand Down Expand Up @@ -247,17 +241,29 @@
const uuid = gZenUIManager.generateUuidv4();
const userContextId = tab.getAttribute("usercontextid");

let entry = null;

if(tab.getAttribute("zen-pinned-entry")) {
entry = JSON.parse(tab.getAttribute("zen-pinned-entry"));
}

await ZenPinnedTabsStorage.savePin({
uuid,
title: tab.label || browser.contentTitle,
url: browser.currentURI.spec,
title: entry?.title || tab.label || browser.contentTitle,
url: entry?.url || browser.currentURI.spec,
containerTabId: userContextId ? parseInt(userContextId, 10) : 0,
workspaceUuid: tab.getAttribute("zen-workspace-id"),
isEssential: tab.getAttribute("zen-essential") === "true"
});

tab.setAttribute("zen-pin-id", uuid);

// This is used while migrating old pins to new system - we don't want to refresh when migrating
if (tab.getAttribute("zen-pinned-entry")) {
tab.removeAttribute("zen-pinned-entry");
return;
}

await this._refreshPinnedTabs();
}

Expand Down
26 changes: 16 additions & 10 deletions src/browser/components/tabbrowser/content/tabbrowser-js.patch
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
diff --git a/browser/components/tabbrowser/content/tabbrowser.js b/browser/components/tabbrowser/content/tabbrowser.js
index 14de79b543cf07b04d06ef5a3f94d9aa988ea39a..5c373d088cfb59ac0c48035e8b9928ee3ac9ee42 100644
index 14de79b543cf07b04d06ef5a3f94d9aa988ea39a..af0f2a13e957331d48643fe4430408924c55b08c 100644
--- a/browser/components/tabbrowser/content/tabbrowser.js
+++ b/browser/components/tabbrowser/content/tabbrowser.js
@@ -462,11 +462,26 @@
Expand Down Expand Up @@ -106,7 +106,7 @@ index 14de79b543cf07b04d06ef5a3f94d9aa988ea39a..5c373d088cfb59ac0c48035e8b9928ee
if (insertTab) {
// insert the tab into the tab container in the correct position
this._insertTabAtIndex(t, {
@@ -3291,6 +3319,20 @@
@@ -3291,6 +3319,23 @@
) {
tabWasReused = true;
tab = this.selectedTab;
Expand All @@ -123,11 +123,14 @@ index 14de79b543cf07b04d06ef5a3f94d9aa988ea39a..5c373d088cfb59ac0c48035e8b9928ee
+ if (tabData.zenDefaultUserContextId) {
+ tab.setAttribute("zenDefaultUserContextId", "true");
+ }
+ if (tabData.zenPinnedEntry) {
+ tab.setAttribute("zen-pinned-entry", tabData.zenPinnedEntry);
+ }
+
if (!tabData.pinned) {
this.unpinTab(tab);
} else {
@@ -3304,6 +3346,9 @@
@@ -3304,6 +3349,9 @@
restoreTabsLazily && !select && !tabData.pinned;

let url = "about:blank";
Expand All @@ -137,7 +140,7 @@ index 14de79b543cf07b04d06ef5a3f94d9aa988ea39a..5c373d088cfb59ac0c48035e8b9928ee
if (tabData.entries?.length) {
let activeIndex = (tabData.index || tabData.entries.length) - 1;
// Ensure the index is in bounds.
@@ -3340,6 +3385,18 @@
@@ -3340,6 +3388,21 @@
preferredRemoteType,
});

Expand All @@ -152,19 +155,22 @@ index 14de79b543cf07b04d06ef5a3f94d9aa988ea39a..5c373d088cfb59ac0c48035e8b9928ee
+ }
+ if (tabData.zenDefaultUserContextId) {
+ tab.setAttribute("zenDefaultUserContextId", "true");
+ }
+ if (tabData.zenPinnedEntry) {
+ tab.setAttribute("zen-pinned-entry", tabData.zenPinnedEntry);
+ }
if (select) {
tabToSelect = tab;
}
@@ -3374,7 +3431,6 @@
@@ -3374,7 +3437,6 @@
this.tabContainer._invalidateCachedTabs();
}
}
-
tab.initialize();
}

@@ -4148,6 +4204,13 @@
@@ -4148,6 +4210,13 @@
TelemetryStopwatch.start("FX_TAB_CLOSE_TIME_NO_ANIM_MS", aTab);
}

Expand All @@ -178,7 +184,7 @@ index 14de79b543cf07b04d06ef5a3f94d9aa988ea39a..5c373d088cfb59ac0c48035e8b9928ee
// Handle requests for synchronously removing an already
// asynchronously closing tab.
if (!animate && aTab.closing) {
@@ -4163,6 +4226,10 @@
@@ -4163,6 +4232,10 @@
// state).
let tabWidth = window.windowUtils.getBoundsWithoutFlushing(aTab).width;

Expand All @@ -189,7 +195,7 @@ index 14de79b543cf07b04d06ef5a3f94d9aa988ea39a..5c373d088cfb59ac0c48035e8b9928ee
if (
!this._beginRemoveTab(aTab, {
closeWindowFastpath: true,
@@ -5123,10 +5190,10 @@
@@ -5123,10 +5196,10 @@
SessionStore.deleteCustomTabValue(aTab, "hiddenBy");
},

Expand All @@ -202,15 +208,15 @@ index 14de79b543cf07b04d06ef5a3f94d9aa988ea39a..5c373d088cfb59ac0c48035e8b9928ee
aTab.selected ||
aTab.closing ||
// Tabs that are sharing the screen, microphone or camera cannot be hidden.
@@ -7042,6 +7109,7 @@
@@ -7042,6 +7115,7 @@
aWebProgress.isTopLevel
) {
this.mTab.setAttribute("busy", "true");
+ if (!this.mTab.selected) this.mTab.setAttribute("unread", "true");
gBrowser._tabAttrModified(this.mTab, ["busy"]);
this.mTab._notselectedsinceload = !this.mTab.selected;
gBrowser.syncThrobberAnimations(this.mTab);
@@ -7874,7 +7942,7 @@ var TabContextMenu = {
@@ -7874,7 +7948,7 @@ var TabContextMenu = {
);
contextUnpinSelectedTabs.hidden =
!this.contextTab.pinned || !multiselectionContext;
Expand Down
Loading