fix(09): ThemeSessionBridge ignores server 'system' to preserve existing client theme
Migration 084 backfilled theme='system' for all existing users. The bridge
was then calling setTheme('system') on every signed-in client, clobbering
existing localStorage values (e.g. user previously chose 'dark', got reset
to OS preference). Treat server 'system' as 'no explicit opinion' — only
enforce explicit 'light'/'dark' from the server.
Tradeoff: explicit 'system' selection on one device won't propagate to a
device that has 'light'/'dark' cached. Acceptable — users can re-select.
This commit is contained in:
parent
58816bbdfe
commit
2a3e89c753
1 changed files with 5 additions and 5 deletions
|
|
@ -23,11 +23,11 @@ export function ThemeSessionBridge() {
|
|||
useEffect(() => {
|
||||
if (!session?.user) return;
|
||||
const serverTheme = (session.user as SessionUserWithTheme).theme;
|
||||
if (
|
||||
serverTheme === 'light' ||
|
||||
serverTheme === 'dark' ||
|
||||
serverTheme === 'system'
|
||||
) {
|
||||
// Only enforce explicit choices. 'system' is the column default and may
|
||||
// mean "no opinion yet" — don't clobber a user's existing client preference
|
||||
// (especially relevant on first load after the migration that backfilled
|
||||
// every existing user to 'system').
|
||||
if (serverTheme === 'light' || serverTheme === 'dark') {
|
||||
if (serverTheme !== theme) {
|
||||
setTheme(serverTheme);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue