import { useState } from 'react'; import { X, RefreshCcw, Check, CheckCircle2, Trash2, Database, Volume2, Activity, PlayCircle } from 'lucide-react'; import { useTheme } from '../context/ThemeContext'; import { usePlayer } from '../context/PlayerContext'; interface SettingsModalProps { isOpen: boolean; onClose: () => void; } export default function SettingsModal({ isOpen, onClose }: SettingsModalProps) { const { theme, toggleTheme } = useTheme(); const { qualityPreference, setQualityPreference } = usePlayer(); const [isUpdating, setIsUpdating] = useState(false); const [updateStatus, setUpdateStatus] = useState<'idle' | 'loading' | 'success' | 'error'>('idle'); const [updateLog, setUpdateLog] = useState(''); const [isClearingCache, setIsClearingCache] = useState(false); if (!isOpen) return null; const handleUpdateYtdlp = async () => { if (isUpdating) return; setIsUpdating(true); setUpdateStatus('loading'); setUpdateLog(''); try { const response = await fetch('/api/settings/update-ytdlp', { method: 'POST' }); const data = await response.json(); if (response.ok) { setUpdateStatus('success'); setUpdateLog(data.output || 'Update successful.'); } else { setUpdateStatus('error'); setUpdateLog(data.error || 'Update failed.'); } } catch (e) { setUpdateStatus('error'); setUpdateLog('Network error occurred.'); } finally { setIsUpdating(false); } }; const handleClearCache = () => { setIsClearingCache(true); // Wipe common caches localStorage.removeItem('ytm_browse_cache_v8'); localStorage.removeItem('ytm_browse_cache_v7'); localStorage.removeItem('artist_photos_cache_v5'); localStorage.removeItem('artist_photos_cache_v6'); // Short delay for feedback setTimeout(() => { setIsClearingCache(false); alert("Cache cleared successfully! The app will reload fresh data."); }, 800); }; const isApple = theme === 'apple'; return (
{/* Modal Container */}
e.stopPropagation()} > {/* Header */}

Settings

{/* Scrollable Content */}
{/* Appearance Section */}
Design System
{/* Spotify Theme */} {/* Apple Music Theme */}
{/* Audio Section */}
Audio Experience
{(['auto', 'high', 'normal', 'low'] as const).map((q) => ( ))}

High quality requires a stable internet connection for seamless playback.

{/* System Section */}
System & Storage
{/* Core Update */}
Core Update yt-dlp nightly

Keep the extraction engine fresh for new content.

{/* Clear Cache */}
Clear Local Cache

Wipe browse and image caches if data feels stale.

{/* Logs Reveal */} {(updateStatus !== 'idle' || updateLog) && (
Operation Log
{updateLog || 'Initializing...'} {updateStatus === 'loading' && _}
)}
KV Spotify Clone v1.0.0
); }