Fix crash on existing saves missing researchQueue by merging persisted state with defaults
CI / build-and-push (push) Successful in 27s
CI / build-and-push (push) Successful in 27s
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1481,12 +1481,19 @@ export const useGameStore = create<Store>()(
|
|||||||
infraNav: { level: 'clusters' },
|
infraNav: { level: 'clusters' },
|
||||||
} as unknown as Store;
|
} as unknown as Store;
|
||||||
}
|
}
|
||||||
const s = _persisted as Record<string, unknown>;
|
return _persisted as Store;
|
||||||
const research = s.research as Record<string, unknown>;
|
},
|
||||||
if (!research.researchQueue) {
|
merge: (persisted, current) => {
|
||||||
s.research = { ...research, researchQueue: [] };
|
const p = persisted as Record<string, unknown>;
|
||||||
|
const c = current as unknown as Record<string, unknown>;
|
||||||
|
const merged = { ...c, ...p };
|
||||||
|
for (const key of Object.keys(c)) {
|
||||||
|
if (p[key] != null && typeof p[key] === 'object' && !Array.isArray(p[key])
|
||||||
|
&& typeof c[key] === 'object' && !Array.isArray(c[key])) {
|
||||||
|
merged[key] = { ...c[key] as Record<string, unknown>, ...p[key] as Record<string, unknown> };
|
||||||
}
|
}
|
||||||
return s as unknown as Store;
|
}
|
||||||
|
return merged as unknown as Store;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|||||||
Reference in New Issue
Block a user