Skip to content

Commit 6a8120b

Browse files
committed
save
1 parent 6bf8dc5 commit 6a8120b

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/pages/toggles/index.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { callAthena, ParamValue } from '../../api/athena'
22
import { BackButton } from '../../components/BackButton'
33
import { TopAppBar } from '../../components/TopAppBar'
44
import { useAsyncMemo, useRouteParams } from '../../utils/hooks'
5+
import { useStorage } from '../../utils/storage'
56
import { SettingCategory, SettingDefinition, SETTINGS } from './settings'
67
import { Button } from '../../components/Button'
78
import { Toggle } from '../../components/Toggle'
@@ -465,7 +466,7 @@ export const Component = () => {
465466
const [changes, setChanges] = useState<Record<string, string>>({})
466467
const [saving, setSaving] = useState(false)
467468
const [savedValues, setSavedValues] = useState<Record<string, string>>({})
468-
const [openSection, setOpenSection] = useState<SettingCategory | null>('models')
469+
const [openSection, setOpenSection] = useStorage('togglesOpenTab')
469470

470471
const res = useAsyncMemo(() => callAthena({ type: 'getAllParams', dongleId, params: {} }), [dongleId])
471472

@@ -525,7 +526,7 @@ export const Component = () => {
525526
setSaving(false)
526527
}
527528

528-
const toggleSection = (cat: SettingCategory) => setOpenSection((prev) => (prev === cat ? null : cat))
529+
const toggleSection = (cat: SettingCategory) => setOpenSection(openSection === cat ? null : cat)
529530

530531
const changeCount = Object.keys(changes).length
531532
const isLoading = res === undefined

src/utils/storage.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ const STORAGES = {
1212
statsTime: (): 'all' | 'week' => 'all',
1313
routesType: (): 'all' | 'preserved' => 'all',
1414
analyzeService: (): Service => 'peripheralState',
15+
togglesOpenTab: (): string | null => 'models',
1516

1617
unitFormat: (): UnitFormat => {
1718
if (typeof navigator === 'undefined') return 'metric'

0 commit comments

Comments
 (0)