Skip to content

Commit

Permalink
fix(getCurrentTheme): fix light theme switching
Browse files Browse the repository at this point in the history
  • Loading branch information
nurikk committed Oct 4, 2023
1 parent a9c2291 commit 91d8508
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,13 @@ const THEME_STORAGE_KEY = 'z2m-theme';

export const getCurrentTheme = (): Theme => {
const prefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
return local.getItem<Theme>(THEME_STORAGE_KEY) ?? prefersDark ? 'dark' : 'light';
const selectedTheme = local.getItem<Theme>(THEME_STORAGE_KEY);
return selectedTheme || (prefersDark ? 'dark' : 'light');
};
export const saveCurrentTheme = (theme: string): void => local.setItem(THEME_STORAGE_KEY, theme);
export const saveCurrentTheme = (theme: string): void => {
console.log('save', theme);
local.setItem(THEME_STORAGE_KEY, theme);
}


export const debounceArgs = (fn: (...args: any) => any, options?: Record<string, any>) => {
Expand Down

0 comments on commit 91d8508

Please sign in to comment.