From 696a2148f0faf5dafe2062c58f8419458a8ae175 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristijan=20Ribari=C4=87?= Date: Thu, 7 Nov 2024 11:40:44 +0100 Subject: [PATCH] (fix) Migrate pinned tabs from older Zen versions If there are no pinned tabs in the database on startup, assume it's a migration from an older version and save all currently pinned tabs to the database. Previously, Zen would remove any pinned tabs that didn't have a `zen-pin-id` attribute, which would occur during migration. This change ensures that pinned tabs are preserved during upgrades. --- src/browser/base/zen-components/ZenPinnedTabManager.mjs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/browser/base/zen-components/ZenPinnedTabManager.mjs b/src/browser/base/zen-components/ZenPinnedTabManager.mjs index 5238907c9..8d6aa83e8 100644 --- a/src/browser/base/zen-components/ZenPinnedTabManager.mjs +++ b/src/browser/base/zen-components/ZenPinnedTabManager.mjs @@ -96,10 +96,13 @@ _initializePinnedTabs() { const pins = this._pinsCache; if (!pins?.length) { - // If there are no pins, we should remove any existing pinned tabs + // If there are no pins in the database it's probably migration from an older version - save all pinned tabs to the database for (let tab of gBrowser.tabs) { - if (tab.pinned && !tab.getAttribute("zen-pin-id")) { - gBrowser.removeTab(tab); + if (tab.pinned) { + if(tab.hasAttribute("zen-pin-id")) { + tab.removeAttribute("zen-pin-id"); + } + this._setPinnedAttributes(tab); } } return;