Skip to content

Commit dc0abb7

Browse files
authored
Merge pull request #25 from mgxv/refactor/derive-getprefs-from-defaults
Derive getPrefs() keys from DEFAULTS to remove manual enumeration
2 parents 2a192f3 + 3aaa173 commit dc0abb7

1 file changed

Lines changed: 5 additions & 8 deletions

File tree

electron/core/store.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,11 @@ export async function initStore(): Promise<void> {
1616
}
1717

1818
export function getPrefs(): Prefs {
19-
return {
20-
systemTheme: _store.get("systemTheme"),
21-
defaultZoom: _store.get("defaultZoom"),
22-
showDockBadge: _store.get("showDockBadge"),
23-
launchAtStartup: _store.get("launchAtStartup"),
24-
crashReporting: _store.get("crashReporting"),
25-
notificationsEnabled: _store.get("notificationsEnabled"),
26-
};
19+
const prefs = {} as Prefs;
20+
for (const key of Object.keys(DEFAULTS) as (keyof Prefs)[]) {
21+
prefs[key] = _store.get(key) as never;
22+
}
23+
return prefs;
2724
}
2825

2926
export function getPref<K extends keyof Prefs>(key: K): Prefs[K] {

0 commit comments

Comments
 (0)