Initial miaojingAI project with image resolution guard
This commit is contained in:
19
src/components/account-theme-sync.tsx
Normal file
19
src/components/account-theme-sync.tsx
Normal file
@@ -0,0 +1,19 @@
|
||||
'use client';
|
||||
|
||||
import { useEffect } from 'react';
|
||||
import { useTheme } from 'next-themes';
|
||||
import { useAuth } from '@/lib/auth-store';
|
||||
|
||||
export function AccountThemeSync() {
|
||||
const { isLoggedIn, user } = useAuth();
|
||||
const { theme, setTheme } = useTheme();
|
||||
|
||||
useEffect(() => {
|
||||
if (!isLoggedIn || !user?.preferredTheme) return;
|
||||
if (theme !== user.preferredTheme) {
|
||||
setTheme(user.preferredTheme);
|
||||
}
|
||||
}, [isLoggedIn, user?.preferredTheme, theme, setTheme]);
|
||||
|
||||
return null;
|
||||
}
|
||||
Reference in New Issue
Block a user