refactor: stabilize game, tutor, and analysis flows

This commit is contained in:
Stefan
2026-04-02 12:41:00 +02:00
parent dd5b4b9b95
commit c8a1325798
35 changed files with 2258 additions and 196 deletions
+9 -2
View File
@@ -11,7 +11,6 @@ export type SavedGame = {
updatedAt: number;
evaluation?: Pick<StockfishEvaluation, "score" | "mate" | "depth"> | null;
language?: SupportedLanguage;
apiKey?: string | null;
};
const STORAGE_KEY = "chess_tutor_saves";
@@ -24,7 +23,15 @@ const parseSavedGames = (): SavedGame[] => {
try {
const data = JSON.parse(raw);
if (!Array.isArray(data)) return [];
return data.filter(Boolean);
return data.filter(Boolean).map((game) => {
if (game && typeof game === "object" && "apiKey" in game) {
const safeGame = { ...(game as SavedGame & { apiKey?: string | null }) };
delete safeGame.apiKey;
return safeGame;
}
return game as SavedGame;
});
} catch (e) {
console.error("Failed to parse saved games", e);
return [];