diff --git a/src/browser/base/zen-components/ZenPinnedTabManager.mjs b/src/browser/base/zen-components/ZenPinnedTabManager.mjs index 7c3544bec..18794d8e0 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); } } @@ -222,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(); @@ -240,13 +245,15 @@ 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"), - workspaceUuid: tab.getAttribute("zen-workspace-id") + containerTabId: userContextId ? parseInt(userContextId, 10) : 0, + workspaceUuid: tab.getAttribute("zen-workspace-id"), + isEssential: tab.getAttribute("zen-essential") === "true" }); tab.setAttribute("zen-pin-id", uuid); @@ -369,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); } @@ -381,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); } } @@ -400,13 +413,17 @@ document.getElementById('tabContextMenu').appendChild(elements); const element = window.MozXULElement.parseXULToFragment(` -