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
+2 -4
View File
@@ -75,10 +75,8 @@
})) }))
} }
if (tempTheme) { theme = loadedTheme
theme = loadedTheme themeLoaded = true
themeLoaded = true
}
} else { } else {
themeLoaded = true themeLoaded = true
} }
+30 -18
View File
@@ -145,6 +145,7 @@ export class ThemeManager {
// Remove current theme if exists // Remove current theme if exists
if (this.currentTheme) { if (this.currentTheme) {
console.debug('[ThemeManager] Removing current theme'); console.debug('[ThemeManager] Removing current theme');
await this.removeTheme(this.currentTheme); await this.removeTheme(this.currentTheme);
} }
@@ -185,8 +186,12 @@ export class ThemeManager {
settingsState.DarkMode = theme.forceDark; settingsState.DarkMode = theme.forceDark;
} }
if (theme.defaultColour) { // Use the stored selected color if available, otherwise use the default
console.debug('[ThemeManager] Setting color:', theme.defaultColour); 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; 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 // Restore original settings
if (settingsState.originalSelectedColor) { if (settingsState.originalSelectedColor) {
console.debug('[ThemeManager] Restoring original color:', settingsState.originalSelectedColor); console.debug('[ThemeManager] Restoring original color:', settingsState.originalSelectedColor);
@@ -489,14 +502,13 @@ export class ThemeManager {
// Update previousImageVariableNames // Update previousImageVariableNames
this.previousImageVariableNames = newImageVariableNames; this.previousImageVariableNames = newImageVariableNames;
// Apply theme settings only if this is a new theme // Apply theme settings
if (!theme.webURL) { if (forceDark !== undefined) {
if (forceDark !== undefined) { settingsState.DarkMode = forceDark;
settingsState.DarkMode = forceDark; }
}
if (defaultColour) { if (defaultColour) {
settingsState.selectedColor = defaultColour; settingsState.selectedColor = defaultColour;
}
} }
} catch (error) { } catch (error) {
console.error('[ThemeManager] Error previewing theme:', error); console.error('[ThemeManager] Error previewing theme:', error);
@@ -555,14 +567,14 @@ export class ThemeManager {
this.previousImageVariableNames = newImageVariableNames; this.previousImageVariableNames = newImageVariableNames;
} }
// Update theme settings only if this is a new theme // Always apply dark mode setting
if (!theme.webURL) { if (theme.forceDark !== undefined) {
if (theme.forceDark !== undefined) { settingsState.DarkMode = theme.forceDark;
settingsState.DarkMode = theme.forceDark; }
}
if (theme.defaultColour) { // Only apply color if this is a new theme
settingsState.selectedColor = theme.defaultColour; if (!theme.webURL && theme.defaultColour) {
} settingsState.selectedColor = theme.defaultColour;
} }
} catch (error) { } catch (error) {
console.error('[ThemeManager] Error updating theme preview:', error); console.error('[ThemeManager] Error updating theme preview:', error);