From 6ccf5053cdf1779d393262a9e8d230927ffdae9c Mon Sep 17 00:00:00 2001 From: "mr. m" Date: Mon, 28 Apr 2025 11:48:34 +0200 Subject: [PATCH 1/2] fix: Fixed spelling on function name and auto-workspace switching, b=(no-bug), c=workspaces --- src/zen/workspaces/ZenWorkspaces.mjs | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/zen/workspaces/ZenWorkspaces.mjs b/src/zen/workspaces/ZenWorkspaces.mjs index d9247149d..676fd4b58 100644 --- a/src/zen/workspaces/ZenWorkspaces.mjs +++ b/src/zen/workspaces/ZenWorkspaces.mjs @@ -684,10 +684,10 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature { } getActiveWorkspaceFromCache() { - return this.getWoekspaceFromId(this.activeWorkspace); + return this.getWorkspaceFromId(this.activeWorkspace); } - getWoekspaceFromId(id) { + getWorkspaceFromId(id) { try { return this._workspaceCache.workspaces.find((workspace) => workspace.uuid === id); } catch (e) { @@ -710,7 +710,7 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature { const activeWorkspaceId = this.activeWorkspace; if (activeWorkspaceId) { - const activeWorkspace = this.getWoekspaceFromId(activeWorkspaceId); + const activeWorkspace = this.getWorkspaceFromId(activeWorkspaceId); // Set the active workspace ID to the first one if the one with selected id doesn't exist if (!activeWorkspace) { this.activeWorkspace = this._workspaceCache.workspaces[0]?.uuid; @@ -2384,7 +2384,7 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature { const workspaceIndicator = document.querySelector( `#zen-current-workspace-indicator-container .zen-workspace-tabs-section[zen-workspace-id="${workspaceId}"]` ); - const workspaceObject = this.getWoekspaceFromId(workspaceId); + const workspaceObject = this.getWorkspaceFromId(workspaceId); const essentialContainer = this.getEssentialsSection(workspaceObject.containerTabId); this._updateMarginTopPinnedTabs(arrowScrollbox, pinnedContainer, essentialContainer, workspaceIndicator, forAnimation); this.updateShouldHideSeparator(arrowScrollbox, pinnedContainer); @@ -2405,7 +2405,8 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature { if (tab.hasAttribute('change-workspace') && this.moveTabToWorkspace(tab, workspaceID)) { this._lastSelectedWorkspaceTabs[workspaceID] = gZenGlanceManager.getTabOrGlanceParent(tab); tab.removeAttribute('change-workspace'); - await this.changeWorkspace({ uuid: workspaceID, containerTabId: tab.getAttribute('usercontextid') }, { onInit: true }); + const workspace = this.getWorkspaceFromId(workspaceID); + await this.changeWorkspace(workspace); } return; } @@ -2449,7 +2450,7 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature { // Switch workspace if needed if (workspaceID && workspaceID !== activeWorkspace.uuid && this._hasInitializedTabsStrip) { - const workspaceToChange = this.getWoekspaceFromId(workspaceID); + const workspaceToChange = this.getWorkspaceFromId(workspaceID); await this.changeWorkspace(workspaceToChange); } } @@ -2634,7 +2635,7 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature { // Tab browser utilities createContainerTabMenu(event) { let window = event.target.ownerGlobal; - const workspace = this.getWoekspaceFromId(this._contextMenuId); + const workspace = this.getWorkspaceFromId(this._contextMenuId); let containerTabId = workspace.containerTabId; return window.createUserContextMenu(event, { isContextMenu: true, @@ -2831,7 +2832,7 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature { (workspace) => workspace.containerTabId + 0 === containerTabId ); } else { - workspaceToSwitch = this.getWoekspaceFromId(tab.getAttribute('zen-workspace-id')); + workspaceToSwitch = this.getWorkspaceFromId(tab.getAttribute('zen-workspace-id')); } if (!workspaceToSwitch) { console.error('No workspace found for tab, cannot switch'); From be244cfe5af16413997396a100c8fe4e6672dba1 Mon Sep 17 00:00:00 2001 From: Slowlife01 Date: Tue, 29 Apr 2025 14:13:01 +0700 Subject: [PATCH 2/2] fix: cache initial pinned tabs favicon, b=(no-bug), c=tabs, welcome --- src/zen/tabs/ZenPinnedTabManager.mjs | 19 +++++++++++++++++-- src/zen/welcome/ZenWelcome.mjs | 27 +++++++++++++++++++++++++-- 2 files changed, 42 insertions(+), 4 deletions(-) diff --git a/src/zen/tabs/ZenPinnedTabManager.mjs b/src/zen/tabs/ZenPinnedTabManager.mjs index f68fa1174..40a04a0ae 100644 --- a/src/zen/tabs/ZenPinnedTabManager.mjs +++ b/src/zen/tabs/ZenPinnedTabManager.mjs @@ -83,8 +83,23 @@ onTabIconChanged(tab, url = null) { const iconUrl = url ?? tab.iconImage.src; - if (tab.hasAttribute('zen-essential')) { - tab.querySelector('.tab-background').style.setProperty('--zen-tab-icon', `url(${iconUrl})`); + if (!iconUrl) { + try { + setTimeout(() => { + PlacesUtils.favicons.getFaviconURLForPage( + tab.linkedBrowser.currentURI, + (url) => { + if (url) gBrowser.setIcon(tab, url.spec); + }, + + 0 + ); + }); + } catch {} + } else { + if (tab.hasAttribute('zen-essential')) { + tab.querySelector('.tab-background').style.setProperty('--zen-tab-icon', `url(${iconUrl})`); + } } // TODO: work on this //if (tab.hasAttribute('zen-pinned-changed') || !this._pinsCache) { diff --git a/src/zen/welcome/ZenWelcome.mjs b/src/zen/welcome/ZenWelcome.mjs index 4e1eb8270..9527221a3 100644 --- a/src/zen/welcome/ZenWelcome.mjs +++ b/src/zen/welcome/ZenWelcome.mjs @@ -68,10 +68,9 @@ async function setCachedFaviconForURL(pageUrl, iconURL) { try { - // TODO: This always return "NS_ERROR_NOT_AVAILABLE" for some reason, figure out why await PlacesUtils.favicons.setFaviconForPage( Services.io.newURI(pageUrl), - Services.io.newURI('fake-favicon-uri:' + pageUrl), + Services.io.newURI(iconURL), Services.io.newURI(iconURL) ); } catch (ex) { @@ -84,6 +83,18 @@ ['https://reddit.com/r/zen_browser', 'Zen on Reddit', 'https://private-cdn.zen-browser.app/reddit.png'], ['https://x.com/zen_browser', 'Zen on Twitter', 'https://private-cdn.zen-browser.app/x.png'], ]; + + await PlacesUtils.history.insertMany( + tabs.map((site) => ({ + url: site[0], + visits: [ + { + transition: PlacesUtils.history.TRANSITIONS.TYPED, + }, + ], + })) + ); + for (const site of tabs) { const tab = window.gBrowser.addTrustedTab(site[0], { inBackground: true, @@ -443,6 +454,18 @@ const selectedTabs = document .getElementById('zen-welcome-initial-essentials-browser-sidebar-essentials') .querySelectorAll('.tabbrowser-tab[visuallyselected]'); + + await PlacesUtils.history.insertMany( + [...selectedTabs].map((tab) => ({ + url: tab.getAttribute('data-url'), + visits: [ + { + transition: PlacesUtils.history.TRANSITIONS.TYPED, + }, + ], + })) + ); + for (const tab of selectedTabs) { const url = tab.getAttribute('data-url'); const createdTab = window.gBrowser.addTrustedTab(url, {