diff --git a/src/browser/app/profile/zen-browser.js b/src/browser/app/profile/zen-browser.js index 27e8df897..b6d044329 100644 --- a/src/browser/app/profile/zen-browser.js +++ b/src/browser/app/profile/zen-browser.js @@ -170,6 +170,7 @@ pref('zen.tab-unloader.enabled', true); pref('zen.tab-unloader.timeout-minutes', 20); pref('zen.tab-unloader.excluded-urls', "example.com,example.org"); +pref('zen.pinned-tab-manager.debug', false); pref('zen.pinned-tab-manager.restore-pinned-tabs-to-pinned-url', false); pref('zen.pinned-tab-manager.close-shortcut-behavior', 'switch'); diff --git a/src/browser/base/zen-components/ZenPinnedTabManager.mjs b/src/browser/base/zen-components/ZenPinnedTabManager.mjs index 4473d7656..b19dd7253 100644 --- a/src/browser/base/zen-components/ZenPinnedTabManager.mjs +++ b/src/browser/base/zen-components/ZenPinnedTabManager.mjs @@ -51,6 +51,7 @@ if (!this.enabled) { return; } + this._canLog = Services.prefs.getBoolPref('zen.pinned-tab-manager.debug', false); this.observer = new ZenPinnedTabsObserver(); this._initClosePinnedTabShortcut(); this._insertItemsIntoTabContextMenu(); @@ -71,6 +72,12 @@ await this._refreshPinnedTabs(newWorkspace, { init: onInit }); } + log(message) { + if (this._canLog) { + console.log(`[ZenPinnedTabManager] ${message}`); + } + } + onTabIconChanged(tab, url = null) { const iconUrl = url ?? tab.iconImage.src; if (tab.hasAttribute('zen-essential')) { @@ -128,6 +135,7 @@ this._pinsCache = []; } + this.log(`Initialized pins cache with ${this._pinsCache.length} pins`); return this._pinsCache; } @@ -224,6 +232,7 @@ SessionStore.setTabState(newTab, state); } + this.log(`Created new pinned tab for pin ${pin.uuid} (isEssential: ${pin.isEssential})`); gBrowser.pinTab(newTab); newTab.initialize(); @@ -372,6 +381,7 @@ return; } + this.log(`Setting pinned attributes for tab ${tab.linkedBrowser.currentURI.spec}`); const browser = tab.linkedBrowser; const uuid = gZenUIManager.generateUuidv4(); @@ -413,6 +423,7 @@ return; } + this.log(`Removing pinned attributes for tab ${tab.getAttribute('zen-pin-id')}`); await ZenPinnedTabsStorage.removePin(tab.getAttribute('zen-pin-id')); if (!isClosing) { diff --git a/src/browser/base/zen-components/ZenPinnedTabsStorage.mjs b/src/browser/base/zen-components/ZenPinnedTabsStorage.mjs index 77ae06a0c..7e5ab6017 100644 --- a/src/browser/base/zen-components/ZenPinnedTabsStorage.mjs +++ b/src/browser/base/zen-components/ZenPinnedTabsStorage.mjs @@ -1,6 +1,5 @@ var ZenPinnedTabsStorage = { async init() { - await SessionStore.promiseInitialized; await this._ensureTable(); }, @@ -47,6 +46,7 @@ var ZenPinnedTabsStorage = { CREATE INDEX IF NOT EXISTS idx_zen_pins_changes_uuid ON zen_pins_changes(uuid) `); + await SessionStore.promiseInitialized; this._resolveInitialized(); }); }, diff --git a/src/browser/base/zen-components/ZenWorkspaces.mjs b/src/browser/base/zen-components/ZenWorkspaces.mjs index b02f1bd9c..a9ed01e29 100644 --- a/src/browser/base/zen-components/ZenWorkspaces.mjs +++ b/src/browser/base/zen-components/ZenWorkspaces.mjs @@ -30,9 +30,7 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature { }); async waitForPromises() { - await SessionStore.promiseInitialized; - await this.promiseDBInitialized; - await this.promisePinnedInitialized; + await Promise.all([this.promiseDBInitialized, this.promisePinnedInitialized, SessionStore.promiseInitialized]); } async init() { @@ -384,13 +382,13 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature { } async initializeWorkspaces() { + await this.waitForPromises(); await this.initializeWorkspacesButton(); if (this.workspaceEnabled) { this._initializeWorkspaceCreationIcons(); this._initializeWorkspaceTabContextMenus(); await this.workspaceBookmarks(); window.addEventListener('TabBrowserInserted', this.onTabBrowserInserted.bind(this)); - await this.waitForPromises(); let workspaces = await this._workspaces(); let activeWorkspace = null; if (workspaces.workspaces.length === 0) { @@ -1358,7 +1356,9 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature { this.tabContainer.removeAttribute('dont-animate-tabs'); // Also animate the workspace indicator label this._animateElement(document.getElementById('zen-current-workspace-indicator'), direction, out, () => onAnimationEnd()); - this._animateElement(document.getElementById('tabbrowser-arrowscrollbox-periphery'), direction, out, () => onAnimationEnd()); + this._animateElement(document.getElementById('tabbrowser-arrowscrollbox-periphery'), direction, out, () => + onAnimationEnd() + ); for (const tab of tabs) { this._animateElement(tab, direction, out, () => onAnimationEnd()); }