Refactor ZenTabUnloader and ZenWorkspaces to improve tab unloading logic and enhance session restoration handling

This commit is contained in:
mr. M
2025-02-22 18:19:57 +01:00
parent 3de1673929
commit f7c0b04884
6 changed files with 64 additions and 56 deletions

View File

@@ -38,7 +38,7 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
`;
async waitForPromises() {
await Promise.all([this.promiseDBInitialized, this.promisePinnedInitialized]);
await Promise.all([this.promiseDBInitialized, this.promisePinnedInitialized, SessionStore.promiseAllWindowsRestored]);
}
async init() {
@@ -599,9 +599,16 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
let showed = false;
if (currentTab.pinned) {
this.selectEmptyTab();
gZenTabUnloader.explicitUnloadTabs([currentTab]);
showed = true;
} else {
if (currentTab.isEmpty) {
const currentTabURL = currentTab.linkedBrowser?.currentURI?.spec;
// Check for empty tab being restored
if (
(currentTab.isEmpty &&
(currentTab.getAttribute('image') === gPageIcons[currentTabURL] || !currentTab.hasAttribute('image'))) ||
currentTab.hasAttribute('zen-empty-tab')
) {
this.selectEmptyTab();
gBrowser.removeTab(currentTab);
showed = true;