chore: Perform codebase cleanup and refactor App state management

This commit is contained in:
Yunxiao Xu
2026-02-17 02:34:47 -08:00
parent ec6760b5a7
commit a94cbc7f6d
9 changed files with 90 additions and 46 deletions

View File

@@ -15,9 +15,11 @@ const ThemeContext = createContext<ThemeContextType | undefined>(undefined)
export function ThemeProvider({
children,
initialTheme = "light",
isAuthenticated = false,
}: {
children: React.ReactNode
initialTheme?: Theme
isAuthenticated?: boolean
}) {
const [theme, setThemeState] = useState<Theme>(initialTheme)
@@ -29,10 +31,12 @@ export function ThemeProvider({
const setTheme = async (newTheme: Theme) => {
setThemeState(newTheme)
try {
await AuthService.updateTheme(newTheme)
} catch (error) {
console.error("Failed to sync theme to backend:", error)
if (isAuthenticated) {
try {
await AuthService.updateTheme(newTheme)
} catch (error) {
console.error("Failed to sync theme to backend:", error)
}
}
}