From bf0342eb0617311c667e6e3a533efb7ec60bdc5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristijan=20Ribari=C4=87?= Date: Mon, 4 Nov 2024 22:24:40 +0100 Subject: [PATCH 1/3] Ensure that when adding an essential it is saved correctly in the database. --- .../zen-components/ZenPinnedTabManager.mjs | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/browser/base/zen-components/ZenPinnedTabManager.mjs b/src/browser/base/zen-components/ZenPinnedTabManager.mjs index 7c3544bec..77b1861f7 100644 --- a/src/browser/base/zen-components/ZenPinnedTabManager.mjs +++ b/src/browser/base/zen-components/ZenPinnedTabManager.mjs @@ -154,6 +154,10 @@ newTab.setAttribute("zen-workspace-id", pin.workspaceUuid); } + if (pin.isEssential) { + newTab.setAttribute("zen-essential", "true"); + } + gBrowser.pinTab(newTab); } @@ -178,10 +182,9 @@ delete tab._zenClickEventListener; } break; - // TODO: Do this in a better way. Closing a second window could trigger remove tab and delete it from db - // case "TabClose": - // this._removePinnedAttributes(tab); - // break; + case "TabClose": + this._removePinnedAttributes(tab); + break; default: console.warn('ZenPinnedTabManager: Unhandled tab event', action); break; @@ -189,8 +192,8 @@ } _onTabClick(e) { - const tab = e.target; - if (e.button === 1) { + const tab = e.target?.closest("tab"); + if (e.button === 1 && tab) { this._onCloseTabShortcut(e, tab); } } @@ -246,7 +249,8 @@ title: tab.label || browser.contentTitle, url: browser.currentURI.spec, containerTabId: tab.getAttribute("userContextId"), - workspaceUuid: tab.getAttribute("zen-workspace-id") + workspaceUuid: tab.getAttribute("zen-workspace-id"), + isEssential: tab.getAttribute("zen-essential") === "true" }); tab.setAttribute("zen-pin-id", uuid); From 7ae2d6d5bb26d741b5a5ef64a557df58e76982f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristijan=20Ribari=C4=87?= Date: Tue, 5 Nov 2024 08:06:54 +0100 Subject: [PATCH 2/3] Fix: Parse user context ID correctly when pinning tabs This commit fixes an issue where the user context ID was not being parsed correctly when pinning tabs. Previously, the user context ID was being stored as a string, which could lead to unexpected behavior. This commit ensures that the user context ID is parsed as an integer, which is the correct data type. This change will ensure that pinned tabs are stored and retrieved correctly. --- src/browser/base/zen-components/ZenPinnedTabManager.mjs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/browser/base/zen-components/ZenPinnedTabManager.mjs b/src/browser/base/zen-components/ZenPinnedTabManager.mjs index 77b1861f7..a6d36c327 100644 --- a/src/browser/base/zen-components/ZenPinnedTabManager.mjs +++ b/src/browser/base/zen-components/ZenPinnedTabManager.mjs @@ -225,10 +225,12 @@ return; } + const userContextId = tab.getAttribute("usercontextid"); + pin.title = tab.label || browser.contentTitle; pin.url = browser.currentURI.spec; pin.workspaceUuid = tab.getAttribute("zen-workspace-id"); - pin.userContextId = tab.getAttribute("userContextId"); + pin.userContextId = userContextId ? parseInt(userContextId, 10) : 0; await ZenPinnedTabsStorage.savePin(pin); await this._refreshPinnedTabs(); @@ -243,12 +245,13 @@ const browser = tab.linkedBrowser; const uuid = gZenUIManager.generateUuidv4(); + const userContextId = tab.getAttribute("usercontextid"); await ZenPinnedTabsStorage.savePin({ uuid, title: tab.label || browser.contentTitle, url: browser.currentURI.spec, - containerTabId: tab.getAttribute("userContextId"), + containerTabId: userContextId ? parseInt(userContextId, 10) : 0, workspaceUuid: tab.getAttribute("zen-workspace-id"), isEssential: tab.getAttribute("zen-essential") === "true" }); From adfcaa2f09bfd7daee4c640d8d1a4e65e0376840 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristijan=20Ribari=C4=87?= Date: Tue, 5 Nov 2024 15:07:58 +0100 Subject: [PATCH 3/3] feat: Add new icons for essentials context items Updted context menu item showing logic --- .../zen-components/ZenPinnedTabManager.mjs | 21 +++++++++++++++---- .../themes/shared/zen-icons/essential-add.svg | 1 + .../shared/zen-icons/essential-remove.svg | 1 + src/browser/themes/shared/zen-icons/icons.css | 11 ++++++++-- 4 files changed, 28 insertions(+), 6 deletions(-) create mode 100644 src/browser/themes/shared/zen-icons/essential-add.svg create mode 100644 src/browser/themes/shared/zen-icons/essential-remove.svg diff --git a/src/browser/base/zen-components/ZenPinnedTabManager.mjs b/src/browser/base/zen-components/ZenPinnedTabManager.mjs index a6d36c327..18794d8e0 100644 --- a/src/browser/base/zen-components/ZenPinnedTabManager.mjs +++ b/src/browser/base/zen-components/ZenPinnedTabManager.mjs @@ -376,6 +376,9 @@ for (let i = 0; i < tabs.length; i++) { const tab = tabs[i]; tab.setAttribute("zen-essential", "true"); + if(tab.hasAttribute("zen-workspace-id")) { + tab.removeAttribute("zen-workspace-id"); + } if (tab.pinned) { gBrowser.unpinTab(tab); } @@ -388,6 +391,9 @@ for (let i = 0; i < tabs.length; i++) { const tab = tabs[i]; tab.removeAttribute("zen-essential"); + if(ZenWorkspaces.workspaceEnabled && ZenWorkspaces.getActiveWorkspaceFromCache.uuid) { + tab.setAttribute("zen-workspace-id", ZenWorkspaces.getActiveWorkspaceFromCache.uuid); + } gBrowser.unpinTab(tab); } } @@ -407,13 +413,17 @@ document.getElementById('tabContextMenu').appendChild(elements); const element = window.MozXULElement.parseXULToFragment(` -