import { useState, type ReactNode } from 'react' import { Link, useNavigate } from 'react-router-dom' import { Bookmark, ChevronRight, Gauge, Info, Loader2, LogOut, Maximize, RefreshCw, Server, ShieldCheck, UserRound, Wifi, Zap } from 'lucide-react' import { CONFIG, DEBRID_SERVER_ID } from '@/lib/config' import { startServer } from '@app/lib/startServer' import { usePremiumAccess } from '@/hooks/usePremiumAccess' import { useAccessRequests } from '@/hooks/useAccessRequests' import { clearAdminToken } from '@/lib/api' import { cn, initialsOf } from '@/lib/utils' import { useFavorites } from '@/context/FavoritesContext' import { useAppAuth } from '@app/auth/AppAuthProvider' import { updateSettings, useSettings } from '@app/lib/settings' import { APP_VERSION, deviceLabel, isAndroid, isDesktop, isNativeApp } from '@app/native/platform' import { useAvailableUpdate } from '@app/native/updates' import { useInstallUpdate } from '@app/native/installUpdate' import { ServerSheet } from '@app/components/ServerSheet' import { Sheet } from '@app/components/Sheet' import { LogoMark } from '@app/components/Logo' import type { QualityPreference } from '@app/downloads/premiumFile' import { PageHeader } from '@app/components/PageHeader' import { PosterCard } from '@app/components/media' import { useMyList } from '@app/components/MyListRow' import { Button, IconTile, ListRow, ListSection, SegmentedControl, Switch } from '@app/components/kit' const PREMIUM_LABEL: Record = { granted: 'Active', 'sign-in-required': 'Not active', 'not-approved': 'Not active', paused: 'Paused by the admin', 'paused-for-all': 'Paused for everyone right now', suspended: 'Account suspended', 'app-only': 'Active', 'update-required': 'Update the app to use it', } export function ProfileScreen() { const { isAuthenticated, user, signIn, signOut, isLoading } = useAppAuth() const access = usePremiumAccess() const { pending: pendingRequests } = useAccessRequests(access.admin) const settings = useSettings() const [serverOpen, setServerOpen] = useState(false) const [aboutOpen, setAboutOpen] = useState(false) const startsOn = startServer('movie', access.premium, settings) const serverName = startsOn === DEBRID_SERVER_ID ? 'Premium' : CONFIG.PROVIDER_NAMES[startsOn] const premiumStatus = access.loading ? 'Checking…' : access.admin ? 'Active' : PREMIUM_LABEL[access.reason] ?? 'Not active' return (
{/* Who's signed in, and what they have */}
{/* The titles saved, as posters */} {/* Settings */}
setServerOpen(true)} icon={ } label="Default server" value={serverName} /> } label="Downloads" trailing={ ({ id: q, label: q }))} value={settings.downloadQuality} onChange={(q) => updateSettings({ downloadQuality: q })} className="w-[156px]" /> } /> {isDesktop && ( } label="Play in full screen" trailing={ updateSettings({ playerFullscreen: v })} />} /> )} {isAndroid && ( } label="Download on Wi-Fi only" trailing={ updateSettings({ wifiOnly: v })} />} /> )} {/* Only the admin sees these; signing in as admin lives under About */} {access.admin && ( } label="Dashboard" trailing={ pendingRequests > 0 ? ( {pendingRequests} ) : undefined } /> clearAdminToken()} icon={ } label="Leave admin mode" accessory="none" /> )} {isNativeApp && } setAboutOpen(true)} icon={ } label="About" value={`${deviceLabel()} ${APP_VERSION}`} />
updateSettings(access.premium ? { defaultServer: id, premiumDefault: id === DEBRID_SERVER_ID } : { defaultServer: id })} />

StreamVault

Version {APP_VERSION} for {deviceLabel()}

StreamVault doesn't host any video — titles play from third-party servers. Title data and images from TMDB; this product uses the TMDB API but is not endorsed or certified by TMDB.

{!access.admin && ( setAboutOpen(false)} className="block pt-2 text-center text-[13px] text-label-3 hover:text-label-2"> Admin sign-in )}
) } function Pill({ children }: { children: ReactNode }) { return {children} } /** Premium's state, as a pill that opens the Premium screen. */ function PremiumPill({ active, label }: { active: boolean; label: string }) { return ( Premium · {label} ) } /** My List as posters — the first handful, and the way to the rest. */ function MyListPreview() { const navigate = useNavigate() const { isAuthenticated } = useAppAuth() const { favorites } = useFavorites() const { data, isLoading } = useMyList() const shown = (data ?? []).filter((m) => m.poster_path).slice(0, PREVIEW_COUNT) return (

My List {favorites.length > 0 && {favorites.length}}

{favorites.length > 0 && ( See all )}
{favorites.length === 0 ? (

{isAuthenticated ? 'Nothing saved yet' : 'Keep a list'}

{isAuthenticated ? 'Press + on any title to save it here.' : 'Sign in to save titles to watch later.'}

) : isLoading && shown.length === 0 ? (
{Array.from({ length: Math.min(favorites.length, PREVIEW_COUNT) }, (_, i) => (
))}
) : (
{shown.map((m, i) => ( ))}
)}
) } /** Two rows of posters: three across on a phone, four in a window, five on a wide one. */ const PREVIEW_COUNT = 10 const PREVIEW_GRID = 'grid grid-cols-3 gap-2.5 sm:grid-cols-4 lg:gap-3 xl:grid-cols-5' /** Past two full rows at this width, a poster waits for a wider one. */ function previewHidden(i: number): string | undefined { if (i >= 8) return 'hidden xl:block' if (i >= 6) return 'hidden sm:block' return undefined } function UpdateRow() { const { update, checking, refetch } = useAvailableUpdate() const { state, install } = useInstallUpdate() const tile = ( ) if (update) { const busy = state.phase === 'downloading' || state.phase === 'installing' return ( !busy && void install(update)} icon={tile} label={busy ? (state.phase === 'installing' ? 'Installing…' : `Downloading${state.phase === 'downloading' && state.percent !== null ? ` ${state.percent}%` : '…'}`) : `Version ${update.version} is out`} detail={state.phase === 'error' ? state.message : undefined} trailing={ busy ? ( ) : ( Update ) } accessory="none" /> ) } return ( : undefined} accessory="none" /> ) }