mirror of
https://github.com/zen-browser/components.git
synced 2025-07-07 23:49:58 +02:00
Update the color theme on panel close instead of on input.
This commit is contained in:
parent
2572fb55f6
commit
8c3b9110b3
1 changed files with 20 additions and 6 deletions
|
@ -350,7 +350,7 @@
|
|||
opacity,
|
||||
rotation,
|
||||
texture,
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
updateNoise(texture) {
|
||||
|
@ -358,9 +358,12 @@
|
|||
wrapper.style.setProperty('--zen-grainy-background-opacity', texture);
|
||||
}
|
||||
|
||||
async onWorkspaceChange(workspace, skipUpdate = false) {
|
||||
async onWorkspaceChange(workspace, skipUpdate = false, theme = null) {
|
||||
const uuid = workspace.uuid;
|
||||
const theme = await ZenWorkspacesStorage.getWorkspaceTheme(uuid);
|
||||
|
||||
if(!theme) {
|
||||
theme = await ZenWorkspacesStorage.getWorkspaceTheme(uuid);
|
||||
}
|
||||
const appWrapepr = document.getElementById('zen-main-app-wrapper');
|
||||
if (!skipUpdate) {
|
||||
appWrapepr.removeAttribute('animating');
|
||||
|
@ -426,7 +429,8 @@
|
|||
}
|
||||
}
|
||||
|
||||
async updateCurrentWorkspace() {
|
||||
async updateCurrentWorkspace(skipSave = true) {
|
||||
this.updated = skipSave;
|
||||
const dots = this.panel.querySelectorAll('.zen-theme-picker-dot');
|
||||
const colors = Array.from(dots).map(dot => {
|
||||
const color = dot.style.getPropertyValue('--zen-theme-picker-dot-color');
|
||||
|
@ -437,9 +441,19 @@
|
|||
return {c: isCustom ? color : color.match(/\d+/g).map(Number), isCustom};
|
||||
});
|
||||
const gradient = this.getTheme(colors, this.currentOpacity, this.currentRotation, this.currentTexture);
|
||||
|
||||
const currentWorkspace = await ZenWorkspaces.getActiveWorkspace();
|
||||
if(!skipSave) {
|
||||
await ZenWorkspacesStorage.saveWorkspaceTheme(currentWorkspace.uuid, gradient);
|
||||
this.onWorkspaceChange(currentWorkspace, true);
|
||||
}
|
||||
await this.onWorkspaceChange(currentWorkspace, true,skipSave ? gradient : null);
|
||||
}
|
||||
|
||||
async handlePanelClose() {
|
||||
if(this.updated) {
|
||||
await this.updateCurrentWorkspace(false);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue