From 1c5044b90debbbe920d9e76ea48882653761d8ce Mon Sep 17 00:00:00 2001 From: "mr. m" Date: Sat, 6 Sep 2025 21:08:16 +0200 Subject: [PATCH] feat: Only collapse folders after pinned restore, b=no-bug, c=folders, tabs --- src/zen/folders/ZenFolders.mjs | 4 +++- src/zen/tabs/ZenPinnedTabManager.mjs | 13 +++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/zen/folders/ZenFolders.mjs b/src/zen/folders/ZenFolders.mjs index 16cf15aa1..a702b6d6e 100644 --- a/src/zen/folders/ZenFolders.mjs +++ b/src/zen/folders/ZenFolders.mjs @@ -875,7 +875,9 @@ // that we want it to initially be collapsed. setTimeout( (folder) => { - folder.collapsed = !!options.collapsed; + gZenPinnedTabManager.promiseInitializedPinned.then(() => { + folder.collapsed = !!options.collapsed; + }); }, 0, folder diff --git a/src/zen/tabs/ZenPinnedTabManager.mjs b/src/zen/tabs/ZenPinnedTabManager.mjs index dd2ffafcb..1efa33aa2 100644 --- a/src/zen/tabs/ZenPinnedTabManager.mjs +++ b/src/zen/tabs/ZenPinnedTabManager.mjs @@ -69,6 +69,9 @@ MAX_ESSENTIALS_TABS = 12; #hasInitializedPins = false; + promiseInitializedPinned = new Promise((resolve) => { + this._resolvePinnedInitializedInternal = resolve; + }); async init() { if (!this.enabled) { @@ -187,10 +190,16 @@ return this._pinsCache; } + #finishedInitializingPins() { + this._resolvePinnedInitializedInternal(); + delete this._resolvePinnedInitializedInternal; + this.#hasInitializedPins = true; + } + async #initializePinnedTabs(init = false) { const pins = this._pinsCache; if (!pins?.length || !init) { - this.#hasInitializedPins = true; + this.#finishedInitializingPins(); return; } @@ -374,7 +383,7 @@ } setTimeout(() => { - this.#hasInitializedPins = true; + this.#finishedInitializingPins(); }, 0); gBrowser._updateTabBarForPinnedTabs();