feat: Add light/dark mode support with backend persistence

This commit is contained in:
Yunxiao Xu
2026-02-17 00:32:15 -08:00
parent 3881ca6fd8
commit de25dc8a4d
17 changed files with 253 additions and 18 deletions

View File

@@ -9,8 +9,10 @@ import { ChatService, type MessageResponse } from "./services/chat"
import { type Conversation } from "./components/layout/HistorySidebar"
import { registerUnauthorizedCallback } from "./services/api"
import { Button } from "./components/ui/button"
import { useTheme } from "./components/theme-provider"
function App() {
const { setTheme } = useTheme()
const [isAuthenticated, setIsAuthenticated] = useState(false)
const [user, setUser] = useState<UserResponse | null>(null)
const [authMode, setAuthMode] = useState<"login" | "register">("login")
@@ -34,6 +36,9 @@ function App() {
const userData = await AuthService.getMe()
setUser(userData)
setIsAuthenticated(true)
if (userData.theme_preference) {
setTheme(userData.theme_preference as "light" | "dark")
}
// Load history after successful auth
loadHistory()
} catch (err: unknown) {
@@ -61,6 +66,9 @@ function App() {
const userData = await AuthService.getMe()
setUser(userData)
setIsAuthenticated(true)
if (userData.theme_preference) {
setTheme(userData.theme_preference as "light" | "dark")
}
loadHistory()
} catch (err: unknown) {
console.error("Failed to fetch user profile after login:", err)