fix: the theme align with the system
This commit is contained in:
@@ -33,10 +33,9 @@ export const getStorageUserSettings = () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export const userSettingsAtom = atomWithStorage<UserSettings>(
|
export const userSettingsAtom = atomWithStorage<UserSettings>('userSettings', {
|
||||||
'userSettings',
|
...getStorageUserSettings()
|
||||||
defaultSettings
|
});
|
||||||
);
|
|
||||||
|
|
||||||
export const userSettingsHelperAtom = atom(
|
export const userSettingsHelperAtom = atom(
|
||||||
(get) => get(userSettingsAtom),
|
(get) => get(userSettingsAtom),
|
||||||
|
|||||||
@@ -53,6 +53,7 @@ export default function useUserSettings() {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (userSettings.mode !== 'auto') return;
|
if (userSettings.mode !== 'auto') return;
|
||||||
|
|
||||||
|
setTheme('auto');
|
||||||
const mediaQuery = window.matchMedia('(prefers-color-scheme: dark)');
|
const mediaQuery = window.matchMedia('(prefers-color-scheme: dark)');
|
||||||
const handleChange = () => {
|
const handleChange = () => {
|
||||||
setTheme('auto');
|
setTheme('auto');
|
||||||
|
|||||||
Reference in New Issue
Block a user