/** * SettingsView - Main settings panel with all app configuration options. * Provides UI for managing notifications, display settings, and advanced options. */ import { useState } from 'react'; import { useStore } from '@renderer/store'; import { Loader2 } from 'lucide-react'; import { useSettingsConfig, useSettingsHandlers } from './hooks'; import { AdvancedSection, ConnectionSection, GeneralSection, NotificationsSection, WorkspaceSection, } from './sections'; import { type SettingsSection, SettingsTabs } from './SettingsTabs'; export const SettingsView = (): React.JSX.Element | null => { const [activeSection, setActiveSection] = useState('general'); const pendingSettingsSection = useStore((s) => s.pendingSettingsSection); const clearPendingSettingsSection = useStore((s) => s.clearPendingSettingsSection); // Consume pending section during render (React-recommended pattern for adjusting state on prop change) const [prevPending, setPrevPending] = useState(null); if (pendingSettingsSection !== prevPending) { setPrevPending(pendingSettingsSection); if (pendingSettingsSection) { setActiveSection(pendingSettingsSection as SettingsSection); clearPendingSettingsSection(); } } const { config, safeConfig, loading, saving, error, setError, setSaving, setConfig, setOptimisticConfig, updateConfig, ignoredRepositoryItems, excludedRepositoryIds, isSnoozed, } = useSettingsConfig(); const handlers = useSettingsHandlers({ config, setSaving, setError, setConfig, setOptimisticConfig, updateConfig, }); // Loading state if (loading) { return (
Loading settings...
); } // Error state if (error && !config) { return (

{error}

); } if (!config) return null; return (
{/* Header */}

Settings

Manage your app preferences

{error && (

{error}

)}
{/* Tabs */} {/* Content */}
{activeSection === 'general' && ( )} {activeSection === 'connection' && } {activeSection === 'workspace' && } {activeSection === 'notifications' && ( )} {activeSection === 'advanced' && ( )}
); };