add user settings

This commit is contained in:
Garret Patti
2026-04-05 18:15:08 -04:00
parent eecee9bc5f
commit 5b5503b7a6
11 changed files with 363 additions and 9 deletions

View File

@@ -0,0 +1,31 @@
'use client'
import { useEffect, useState } from 'react'
import type { UserSettings } from '@/types'
const DEFAULTS: UserSettings = {
mixedAutoplay: true,
mixedLoop: true,
mixedMuted: true,
moviesAutoplay: true,
moviesLoop: false,
moviesMuted: false,
tvAutoplay: true,
tvLoop: false,
tvMuted: false,
}
export function useUserSettings(): UserSettings {
const [settings, setSettings] = useState<UserSettings>(DEFAULTS)
useEffect(() => {
fetch('/api/settings')
.then((r) => (r.ok ? r.json() : null))
.then((data: UserSettings | null) => {
if (data) setSettings(data)
})
.catch(() => {/* fall back to defaults */})
}, [])
return settings
}