feat: add Aurora Glass built-in theme
This commit is contained in:
+16
-2
@@ -451,11 +451,25 @@ export const useThemeStore = create<ThemeState>()(
|
||||
onRehydrateStorage: () => {
|
||||
return (state) => {
|
||||
if (state) {
|
||||
// Ensure built-in themes are always present after rehydration
|
||||
// Ensure built-in themes are always present after rehydration.
|
||||
// Drop persisted themes that were flagged builtIn but no longer
|
||||
// exist in BUILTIN_THEMES (e.g. a built-in removed from source) so
|
||||
// stale built-ins don't survive as phantom "user" themes.
|
||||
const builtInIds = new Set(BUILTIN_THEMES.map(t => t.id));
|
||||
const userThemes = state.installedThemes.filter(t => !builtInIds.has(t.id));
|
||||
const userThemes = state.installedThemes.filter(
|
||||
t => !builtInIds.has(t.id) && !t.builtIn
|
||||
);
|
||||
state.installedThemes = [...BUILTIN_THEMES, ...userThemes];
|
||||
|
||||
// If the active theme pointed at a now-removed built-in, fall back
|
||||
// to the default so the UI doesn't reference a missing theme.
|
||||
if (
|
||||
state.activeThemeId &&
|
||||
!state.installedThemes.some(t => t.id === state.activeThemeId)
|
||||
) {
|
||||
state.activeThemeId = null;
|
||||
}
|
||||
|
||||
// Re-apply theme immediately after rehydration
|
||||
const resolvedTheme = state.theme === 'system' ? getSystemTheme() : state.theme;
|
||||
applyTheme(resolvedTheme);
|
||||
|
||||
Reference in New Issue
Block a user