Skip to content

Commit

Permalink
style: add arrow fn
Browse files Browse the repository at this point in the history
  • Loading branch information
fbuireu committed Oct 4, 2024
1 parent 4b77430 commit f73a031
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ const PREFERS_DARK_SCHEME = window.matchMedia("(prefers-color-scheme: dark)");

export const getCurrentTheme = () => localStorage.getItem(THEME_STORAGE_KEY) as ThemeType | null;

function getInitialTheme() {
const getInitialTheme = () => {
const cachedTheme = getCurrentTheme();
const prefersDarkScheme = PREFERS_DARK_SCHEME.matches;

return cachedTheme ?? (prefersDarkScheme ? ThemeType.DARK : ThemeType.LIGHT);
}
};

export function initializeThemeSetter() {
const { THEME_INPUT: THEME_INPUT_SELECTOR, TOGGLE: TOGGLE_SELECTOR } = SELECTORS;
Expand Down Expand Up @@ -56,8 +56,8 @@ export function initializeThemeSetter() {
window.addEventListener("storage", ({ key, newValue }) => {
if (key === THEME_STORAGE_KEY && newValue) {
const newTheme = newValue as ThemeType;
const currentTheme = getCurrentTheme();
if (newTheme !== currentTheme) applyTheme({ theme: newTheme, document });

applyTheme({ theme: newTheme, document });
}
});

Expand Down

0 comments on commit f73a031

Please sign in to comment.