Skip to content

Commit

Permalink
Fix get current theme (#1959)
Browse files Browse the repository at this point in the history
selectedTheme was checked only for the value of 'dark', which is why it was not possible to set the Light Theme forcibly and each page overload returned it to dark.
  • Loading branch information
igo-r authored Apr 3, 2024
1 parent d27a7ce commit 1eb4793
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ const THEME_STORAGE_KEY = 'z2m-theme';
export const getCurrentTheme = (): Theme => {
const prefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
const selectedTheme = local.get(THEME_STORAGE_KEY);
return selectedTheme === 'dark' ? 'dark' : (prefersDark ? 'dark' : 'light');
return ['light', 'dark'].includes(selectedTheme) ? selectedTheme : (prefersDark ? 'dark' : 'light');
};
export const saveCurrentTheme = (theme: string): void => {
console.log('save', theme);
Expand Down

0 comments on commit 1eb4793

Please sign in to comment.