1
0
Fork 1
mirror of https://github.com/zen-browser/desktop.git synced 2025-07-09 17:55:42 +02:00

Refactor ZenWorkspaces initialization and enhance pinned tab management for improved performance and layout

This commit is contained in:
mr. M 2025-02-20 23:17:52 +01:00
parent fbe81666bf
commit 9f8dfddfa8
No known key found for this signature in database
GPG key ID: CBD57A2AEDBDA1FB
5 changed files with 57 additions and 33 deletions

View file

@ -83,18 +83,11 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
if (!this._hasInitializedTabsStrip) {
await this.delayedStartup();
}
await this.promiseSectionsInitialized;
window.addEventListener(
'MozAfterPaint',
async () => {
await SessionStore.promiseAllWindowsRestored;
await this.afterLoadInit();
},
{ once: true }
);
}
async afterLoadInit() {
await this.promiseSectionsInitialized;
await SessionStore.promiseAllWindowsRestored;
console.info('ZenWorkspaces: ZenWorkspaces initialized');
await this.initializeWorkspaces();
@ -209,7 +202,7 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
for (const tab of tabs) {
if (tab.hasAttribute('zen-essential')) {
essentialsContaienr.appendChild(tab);
continue
continue;
} else if (tab.pinned) {
pinnedContainer.insertBefore(tab, pinnedContainer.lastChild);
continue;
@ -595,6 +588,22 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
} catch (e) {
console.error('ZenWorkspaces: Error initializing theme picker', e);
}
this._selectStartPage();
}
}
_selectStartPage() {
const currentTab = gBrowser.selectedTab;
const isEssential = currentTab.hasAttribute('zen-essential');
if (isEssential) {
this.selectEmptyTab();
return;
}
const currentTabUrl = currentTab.linkedBrowser?.currentURI.spec;
console.log('ZenWorkspaces: Current tab URL', currentTabUrl);
if (currentTabUrl === 'about:blank' || currentTabUrl === 'about:newtab' || currentTabUrl === 'about:home') {
this.selectEmptyTab();
gBrowser.removeTab(currentTab);
}
}