Refactor ZenGlanceManager to streamline tab closing logic and improve animation handling

This commit is contained in:
mr. M
2025-02-02 22:58:39 +01:00
parent 5a367fdad0
commit 5fa7d9cc6e

View File

@@ -304,18 +304,12 @@
this.lastCurrentTab.removeAttribute('zen-glance-tab'); this.lastCurrentTab.removeAttribute('zen-glance-tab');
this.lastCurrentTab._closingGlance = true; this.lastCurrentTab._closingGlance = true;
gBrowser.tabContainer._invalidateCachedTabs();
const prevSelected = gBrowser.selectedTab;
if (!isDifferent) { if (!isDifferent) {
gBrowser.selectedTab = this.#currentParentTab; gBrowser.selectedTab = this.#currentParentTab;
} }
if (!(onTabClose && prevSelected === this.lastCurrentTab)) { this._ignoreClose = true;
gBrowser.removeTab(this.lastCurrentTab, { animate: true }); gBrowser.removeTab(this.lastCurrentTab, { animate: true });
} gBrowser.tabContainer._invalidateCachedTabs();
setTimeout(() => {
prevOverlay.remove(); // Just to be sure
}, 0);
this.#currentParentTab.removeAttribute('glance-id'); this.#currentParentTab.removeAttribute('glance-id');
@@ -442,10 +436,9 @@
this._ignoreClose = false; this._ignoreClose = false;
return false; return false;
} }
this._ignoreClose = isDifferent;
this.closeGlance({ onTabClose: true, setNewID: isDifferent ? oldGlanceID : null, isDifferent }); this.closeGlance({ onTabClose: true, setNewID: isDifferent ? oldGlanceID : null, isDifferent });
// only keep continueing tab close if we are not on the currently selected tab // only keep continueing tab close if we are not on the currently selected tab
return true; return !isDifferent;
} }
return false; return false;
} }