fix: Improved workspace icons generation, b=(no-bug), c=common, mods, workspaces

This commit is contained in:
Mr. M
2025-05-18 12:29:26 +02:00
parent 246e3b25a4
commit 148a5eebc2
5 changed files with 34 additions and 14 deletions

View File

@@ -58,7 +58,6 @@ var gZenUIManager = {
}); });
window.addEventListener('TabClose', this.onTabClose.bind(this)); window.addEventListener('TabClose', this.onTabClose.bind(this));
this.tabsWrapper.addEventListener('scroll', this.saveScrollbarState.bind(this));
gZenMediaController.init(); gZenMediaController.init();
}, },

View File

@@ -181,7 +181,11 @@ export class ZenThemeMarketplaceParent extends JSWindowActorParent {
} }
async installTheme(theme) { async installTheme(theme) {
await this.downloadThemeFileContents(theme); try {
await this.downloadThemeFileContents(theme);
} catch (e) {
console.error('ZenThemeMarketplaceParent: Error installing theme', theme.id, e);
}
} }
async checkForThemeChanges() { async checkForThemeChanges() {

View File

@@ -51,22 +51,25 @@
} }
} }
on_ZenWorkspacesUIUpdate(event) { async on_ZenWorkspacesUIUpdate(event) {
this.#updateIcons(); await this.#updateIcons();
this.activeIndex = event.detail.activeIndex; this.activeIndex = event.detail.activeIndex;
} }
set activeIndex(uuid) { set activeIndex(uuid) {
const buttons = this.querySelectorAll('toolbarbutton'); const buttons = this.querySelectorAll('toolbarbutton');
if (!buttons.length) {
return;
}
let i = 0; let i = 0;
let selected = 0; let selected = -1;
for (const button of buttons) { for (const button of buttons) {
if (button.getAttribute('zen-workspace-id') == uuid) { if (button.getAttribute('zen-workspace-id') == uuid) {
selected = i; selected = i;
} else { } else {
button.removeAttribute('active'); button.removeAttribute('active');
} }
selected++; i++;
} }
buttons[selected].setAttribute('active', true); buttons[selected].setAttribute('active', true);
this.setAttribute('selected', selected); this.setAttribute('selected', selected);

View File

@@ -1594,12 +1594,14 @@ var gZenWorkspaces = new (class extends ZenMultiWindowFeature {
browser.gZenWorkspaces._workspaceBookmarksCache = null; browser.gZenWorkspaces._workspaceBookmarksCache = null;
} }
let workspaces = await browser.gZenWorkspaces._workspaces(); let workspaces = await browser.gZenWorkspaces._workspaces();
browser.dispatchEvent( if (clearCache) {
new CustomEvent('ZenWorkspacesUIUpdate', { browser.dispatchEvent(
bubbles: true, new CustomEvent('ZenWorkspacesUIUpdate', {
detail: { workspaces, activeIndex: browser.gZenWorkspaces.activeWorkspace }, bubbles: true,
}) detail: { activeIndex: browser.gZenWorkspaces.activeWorkspace },
); })
);
}
await browser.gZenWorkspaces.workspaceBookmarks(); await browser.gZenWorkspaces.workspaceBookmarks();
workspaceList.innerHTML = ''; workspaceList.innerHTML = '';
workspaceList.parentNode.style.display = 'flex'; workspaceList.parentNode.style.display = 'flex';
@@ -2102,7 +2104,9 @@ var gZenWorkspaces = new (class extends ZenMultiWindowFeature {
element, element,
{ {
transform: existingTransform ? [existingTransform, newTransform] : newTransform, transform: existingTransform ? [existingTransform, newTransform] : newTransform,
paddingTop: existingTransform ? [existingPaddingTop, existingPaddingTop] : existingPaddingTop, paddingTop: existingTransform
? [existingPaddingTop, existingPaddingTop]
: existingPaddingTop,
}, },
{ {
type: 'spring', type: 'spring',
@@ -2441,8 +2445,16 @@ var gZenWorkspaces = new (class extends ZenMultiWindowFeature {
tab.setAttribute('zen-workspace-id', workspace.uuid); tab.setAttribute('zen-workspace-id', workspace.uuid);
} }
} }
window.dispatchEvent(
new CustomEvent('ZenWorkspacesUIUpdate', {
bubbles: true,
detail: { activeIndex: workspace.uuid },
})
);
} }
this.workspaceIcons.activeIndex = workspace.uuid;
setTimeout(gURLBar.formatValue.bind(gURLBar), 0); setTimeout(gURLBar.formatValue.bind(gURLBar), 0);
} }

View File

@@ -11,7 +11,9 @@
align-items: center; align-items: center;
display: flex; display: flex;
font-size: x-small; font-size: x-small;
margin: 0 5px; padding: 0 3px;
margin: 0;
appearance: auto;
position: relative; position: relative;