fix theme warning

This commit is contained in:
Tom (plebeius.eth)
2024-08-26 17:39:27 +02:00
parent 31abe908e3
commit d3d88da24a
4 changed files with 37 additions and 26 deletions
+5 -3
View File
@@ -8,7 +8,7 @@ interface ThemeState {
};
currentTheme: string | null;
setTheme: (category: keyof ThemeState['themes'], theme: string) => void;
getTheme: (category: keyof ThemeState['themes']) => string | null;
getTheme: (category: keyof ThemeState['themes'], updateCurrentTheme?: boolean) => string | null;
loadThemes: () => Promise<void>;
}
@@ -29,10 +29,12 @@ const useThemeStore = create<ThemeState>((set: StoreApi<ThemeState>['setState'],
await themeStore.setItem(category, theme);
set({ themes: updatedThemes, currentTheme: theme });
},
getTheme: (category) => {
getTheme: (category, updateCurrentTheme = true) => {
const currentThemes = get().themes;
const theme = currentThemes[category] || null;
set({ currentTheme: theme });
if (updateCurrentTheme) {
set({ currentTheme: theme });
}
return theme;
},
loadThemes: async () => {