refactor(state): fix code quality findings for nav panel store and prefs

This commit is contained in:
ginnoir
2026-06-11 21:12:20 -05:00
parent 9b2793b264
commit 09e2d06b87
4 changed files with 75 additions and 12 deletions
+14 -1
View File
@@ -21,7 +21,20 @@ export function getPrefs(): GamePrefs {
if (typeof localStorage === 'undefined') return { ...DEFAULTS };
try {
const raw = localStorage.getItem(PREFS_KEY);
if (!raw) return { ...DEFAULTS };
if (!raw) {
const rawV1 = localStorage.getItem('idlegame:prefs:v1');
if (rawV1) {
try {
const parsedV1 = JSON.parse(rawV1);
const migrated = { ...DEFAULTS, ...parsedV1 };
localStorage.setItem(PREFS_KEY, JSON.stringify(migrated));
return migrated;
} catch {
return { ...DEFAULTS };
}
}
return { ...DEFAULTS };
}
return { ...DEFAULTS, ...JSON.parse(raw) };
} catch {
return { ...DEFAULTS };