mirror of
https://github.com/zen-browser/desktop.git
synced 2026-05-20 12:01:27 +00:00
no-bug: Fixed loading bar appearing twice (gh-13337)
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 || [],
|
||||
|
||||
Reference in New Issue
Block a user