feat: Add light/dark mode support with backend persistence
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user