M19: Move sidebarCollapsed from localStorage to electron-store
Sidebar collapsed state was an orphan in localStorage -- not backed up,
lost on portable installs, and inconsistent with every other preference.
Added sidebarCollapsed: boolean to the Settings type and DEFAULT_SETTINGS,
wired it through applySettings' boolean branch, and updated the renderer
store / main.tsx mock defaults. App.tsx now drives the toggle via
updateSettings({ sidebarCollapsed }) instead of localStorage.
typecheck + 242 tests + eslint green.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -130,16 +130,9 @@ function App(): React.JSX.Element {
|
||||
window.api?.getAppVersion?.().then(setVersion).catch(logError('getAppVersion'))
|
||||
}, [])
|
||||
|
||||
// Sidebar collapse, persisted across launches in localStorage.
|
||||
const [collapsed, setCollapsed] = useState(
|
||||
() => localStorage.getItem('aerofetch.sidebarCollapsed') === '1'
|
||||
)
|
||||
const collapsed = useSettings((s) => s.sidebarCollapsed)
|
||||
function toggleCollapsed(): void {
|
||||
setCollapsed((c) => {
|
||||
const next = !c
|
||||
localStorage.setItem('aerofetch.sidebarCollapsed', next ? '1' : '0')
|
||||
return next
|
||||
})
|
||||
updateSettings({ sidebarCollapsed: !collapsed })
|
||||
}
|
||||
// Gate on `loaded` so a returning user's real settings never get clobbered
|
||||
// by a one-frame flash of the (default-false) onboarding state.
|
||||
|
||||
@@ -42,6 +42,7 @@ if (import.meta.env.DEV && !window.api) {
|
||||
hasCompletedOnboarding: true,
|
||||
minimizeToTray: false,
|
||||
launchAtStartup: false,
|
||||
sidebarCollapsed: false,
|
||||
updateToken: ''
|
||||
}
|
||||
// Stands in for the cookies.txt file's mtime — lets the Cookies card's
|
||||
|
||||
@@ -40,6 +40,7 @@ const FALLBACK: Settings = {
|
||||
hasCompletedOnboarding: PREVIEW,
|
||||
minimizeToTray: false,
|
||||
launchAtStartup: false,
|
||||
sidebarCollapsed: false,
|
||||
updateToken: ''
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user