fix: themes custom colour not being completely applied

This commit is contained in:
SethBurkart123
2025-03-28 12:17:37 +11:00
parent c4c50f2c30
commit 7af6acaf38
2 changed files with 32 additions and 22 deletions
+30 -18
View File
@@ -145,6 +145,7 @@ export class ThemeManager {
// Remove current theme if exists
if (this.currentTheme) {
console.debug('[ThemeManager] Removing current theme');
await this.removeTheme(this.currentTheme);
}
@@ -185,8 +186,12 @@ export class ThemeManager {
settingsState.DarkMode = theme.forceDark;
}
if (theme.defaultColour) {
console.debug('[ThemeManager] Setting color:', theme.defaultColour);
// Use the stored selected color if available, otherwise use the default
if (theme.selectedColor) {
console.debug('[ThemeManager] Restoring saved color:', theme.selectedColor);
settingsState.selectedColor = theme.selectedColor;
} else if (theme.defaultColour) {
console.debug('[ThemeManager] Using default color:', theme.defaultColour);
settingsState.selectedColor = theme.defaultColour;
}
@@ -220,6 +225,14 @@ export class ThemeManager {
});
}
if (this.currentTheme) {
// Store the current color with the theme before removing it
await localforage.setItem(this.currentTheme.id, {
...this.currentTheme,
selectedColor: settingsState.selectedColor
});
}
// Restore original settings
if (settingsState.originalSelectedColor) {
console.debug('[ThemeManager] Restoring original color:', settingsState.originalSelectedColor);
@@ -489,14 +502,13 @@ export class ThemeManager {
// Update previousImageVariableNames
this.previousImageVariableNames = newImageVariableNames;
// Apply theme settings only if this is a new theme
if (!theme.webURL) {
if (forceDark !== undefined) {
settingsState.DarkMode = forceDark;
}
if (defaultColour) {
settingsState.selectedColor = defaultColour;
}
// Apply theme settings
if (forceDark !== undefined) {
settingsState.DarkMode = forceDark;
}
if (defaultColour) {
settingsState.selectedColor = defaultColour;
}
} catch (error) {
console.error('[ThemeManager] Error previewing theme:', error);
@@ -555,14 +567,14 @@ export class ThemeManager {
this.previousImageVariableNames = newImageVariableNames;
}
// Update theme settings only if this is a new theme
if (!theme.webURL) {
if (theme.forceDark !== undefined) {
settingsState.DarkMode = theme.forceDark;
}
if (theme.defaultColour) {
settingsState.selectedColor = theme.defaultColour;
}
// Always apply dark mode setting
if (theme.forceDark !== undefined) {
settingsState.DarkMode = theme.forceDark;
}
// Only apply color if this is a new theme
if (!theme.webURL && theme.defaultColour) {
settingsState.selectedColor = theme.defaultColour;
}
} catch (error) {
console.error('[ThemeManager] Error updating theme preview:', error);