@@ -2,11 +2,25 @@ import { Divider } from "@tw/divider";
22import { Heading , Subheading } from "@tw/heading" ;
33import { Input } from "@tw/input" ;
44import { useDownloads } from "@/context/DownloadContext" ;
5+ import { SwitchField , Switch } from "@tw/switch" ;
6+ import { Label } from "@/components/tailwind/fieldset" ;
7+ import { useEffect , useState } from "react" ;
8+
9+ const RETAIN_KEY = 'app_retain_library_prefs' ;
510
611export default function Settings ( ) {
712 const { speedLimitKB, setSpeedLimitKB, formatSpeed, formatLimit } = useDownloads ( ) as any ;
813 // speedLimitKB stored directly as KB/s (decimal). 0 = unlimited.
914 const kbValue = speedLimitKB ;
15+ const [ retainLibraryPrefs , setRetainLibraryPrefs ] = useState < boolean > ( ( ) => {
16+ try {
17+ const v = localStorage . getItem ( RETAIN_KEY ) ;
18+ return v === '1' ;
19+ } catch { return false ; }
20+ } ) ;
21+ useEffect ( ( ) => {
22+ try { localStorage . setItem ( RETAIN_KEY , retainLibraryPrefs ? '1' : '0' ) ; } catch { }
23+ } , [ retainLibraryPrefs ] ) ;
1024
1125 return (
1226 < div className = "flex flex-col h-full overflow-auto pb-12" >
@@ -43,6 +57,22 @@ export default function Settings() {
4357 </ label >
4458 </ div >
4559 </ section >
60+
61+ < section >
62+ < Subheading level = { 2 } > Library</ Subheading >
63+ < div className = "flex flex-col gap-4" >
64+ < SwitchField >
65+ < Switch
66+ name = "retainLibraryPrefs"
67+ color = "indigo"
68+ aria-label = "Retain Library sorting and filter preferences"
69+ checked = { retainLibraryPrefs }
70+ onChange = { ( v : boolean ) => setRetainLibraryPrefs ( v ) }
71+ />
72+ < Label > Retain Sorting and Filter preferences</ Label >
73+ </ SwitchField >
74+ </ div >
75+ </ section >
4676 </ div >
4777 </ div >
4878 ) ;
0 commit comments