mirror of
https://github.com/Portabase/portabase.git
synced 2026-07-14 11:16:13 +02:00
fix(theme): use current theme as fallback in preferences, prevent session override of localStorage
This commit is contained in:
@@ -15,7 +15,13 @@ export function ThemeMetaUpdater() {
|
||||
|
||||
useEffect(() => {
|
||||
if (isPending || !session?.user?.theme) return;
|
||||
setTheme(session.user.theme);
|
||||
// Only apply the DB theme if the browser has no locally stored preference.
|
||||
// This prevents a stale session value from overriding a theme the user
|
||||
// just selected (localStorage is always written first by next-themes).
|
||||
const stored = localStorage.getItem("theme");
|
||||
if (!stored) {
|
||||
setTheme(session.user.theme);
|
||||
}
|
||||
}, [session, isPending, setTheme]);
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
Reference in New Issue
Block a user