From 014eabed3cbdbfd0a4cf07c75d22d0c84cb6f130 Mon Sep 17 00:00:00 2001 From: "mr. m" <91018726+mr-cheffy@users.noreply.github.com> Date: Tue, 21 Apr 2026 01:18:48 +0200 Subject: [PATCH] no-bug: Fixed loading bar appearing twice (gh-13337) --- prefs/zen/glance.yaml | 2 +- src/zen/common/sys/ui/ZenProgressBar.sys.mjs | 17 ++++++++++++++--- src/zen/sessionstore/ZenSessionManager.sys.mjs | 11 +++++++---- 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/prefs/zen/glance.yaml b/prefs/zen/glance.yaml index cf73cddb9..5788dbca1 100644 --- a/prefs/zen/glance.yaml +++ b/prefs/zen/glance.yaml @@ -15,7 +15,7 @@ value: "alt" # ctrl, alt, shift - name: zen.glance.animation-duration - value: 300 # in milliseconds + value: 350 # in milliseconds - name: zen.glance.deactivate-docshell-during-animation value: false diff --git a/src/zen/common/sys/ui/ZenProgressBar.sys.mjs b/src/zen/common/sys/ui/ZenProgressBar.sys.mjs index d1add0fc6..511c68c37 100644 --- a/src/zen/common/sys/ui/ZenProgressBar.sys.mjs +++ b/src/zen/common/sys/ui/ZenProgressBar.sys.mjs @@ -10,6 +10,7 @@ export class ZenProgressBar extends ZenUIComponent { #element = null; #loadingTab = null; #longLoadTimer = null; + #promise = null; init() { this.listenBrowserTabsProgress(); @@ -60,7 +61,8 @@ export class ZenProgressBar extends ZenUIComponent { return this.#element; } - #checkBrowserProgress(webProgress) { + async #checkBrowserProgress(webProgress) { + await this.#promise; const window = this.window; const gBrowser = window.gBrowser; const tab = gBrowser.getTabForBrowser(webProgress); @@ -74,7 +76,7 @@ export class ZenProgressBar extends ZenUIComponent { } } - #hideProgressBar() { + #hideProgressBar(aInstant = false) { const progressBar = this.#element; const window = this.window; if (this.#longLoadTimer) { @@ -86,12 +88,15 @@ export class ZenProgressBar extends ZenUIComponent { if (!progressBar) { return; } + let { promise, resolve } = Promise.withResolvers(); + this.#promise = promise; const callback = () => { delete progressBar._loadingTab; progressBar.remove(); this.#element = null; + resolve(); }; - if (this.window.gReduceMotion) { + if (this.window.gReduceMotion || aInstant) { callback(); return; } @@ -113,6 +118,11 @@ export class ZenProgressBar extends ZenUIComponent { if (this.#loadingTab === aTab) { return; } + if (this.#element) { + return; + } + let { promise, resolve } = Promise.withResolvers(); + this.#promise = promise; this.#loadingTab = aTab; const progressBar = this.#progressBar; progressBar.removeAttribute("fade-out"); @@ -123,5 +133,6 @@ export class ZenProgressBar extends ZenUIComponent { } this.#longLoadTimer = null; }, WAIT_BEFORE_SHOWING_LONG_LOAD); + resolve(); } } diff --git a/src/zen/sessionstore/ZenSessionManager.sys.mjs b/src/zen/sessionstore/ZenSessionManager.sys.mjs index f784e1656..39f2d0eb2 100644 --- a/src/zen/sessionstore/ZenSessionManager.sys.mjs +++ b/src/zen/sessionstore/ZenSessionManager.sys.mjs @@ -290,10 +290,13 @@ export class nsZenSessionManager { console.error("ZenSessionManager: Failed to read session file", e); } this.#sidebar = this._dataFromFile || {}; - if (!this.#sidebar.spaces?.length && !this._shouldRunMigration) { + if ( + !this.#sidebarWithoutCloning.spaces?.length && + !this._shouldRunMigration + ) { this.log( "No spaces data found in session file, running migration", - this.#sidebar + this.#sidebarWithoutCloning ); // If we have no spaces data, we should run migration // to restore them from the database. Note we also do a @@ -304,7 +307,7 @@ export class nsZenSessionManager { if ( Services.prefs.getBoolPref("zen.session-store.log-tab-entries", false) ) { - for (const tab of this.#sidebar.tabs || []) { + for (const tab of this.#sidebarWithoutCloning.tabs || []) { this.log("Tab entry in session file:", tab); } } @@ -492,7 +495,7 @@ export class nsZenSessionManager { delete this._migrationData?.recoveryData; // Restore spaces into the sidebar object if we don't // have any yet. - if (!this.#sidebar.spaces?.length) { + if (!this.#sidebarWithoutCloning.spaces?.length) { this.#sidebar = { ...this.#sidebar, spaces: this._migrationData?.spaces || [],