diff --git a/src/chess_pressure/static/app.js b/src/chess_pressure/static/app.js index 5803200..ee95471 100644 --- a/src/chess_pressure/static/app.js +++ b/src/chess_pressure/static/app.js @@ -422,7 +422,17 @@ const name = (prompt("Save game as:", defaultGameName()) || "").trim(); if (!name) return; const pgn = ChessPressure.toPgn(gameData.headers, gameData.moves); - const saved = getSavedGames(); + let saved = getSavedGames(); + + // Overwrite an existing game with the same name (case-insensitive) instead of + // creating a duplicate; also collapses any pre-existing duplicates. + const key = name.toLowerCase(); + const exists = saved.some((g) => g.name.toLowerCase() === key); + if (exists) { + if (!confirm(`A game named "${name}" already exists. Overwrite it?`)) return; + saved = saved.filter((g) => g.name.toLowerCase() !== key); + } + const id = "g" + Date.now().toString(36); saved.push({ id, name, pgn, savedAt: new Date().toISOString() }); setSavedGames(saved); diff --git a/src/chess_pressure/static/index.html b/src/chess_pressure/static/index.html index ad3b558..9ba8ecb 100644 --- a/src/chess_pressure/static/index.html +++ b/src/chess_pressure/static/index.html @@ -4,7 +4,7 @@ Chess Pressure - + @@ -139,6 +139,6 @@ - + diff --git a/src/chess_pressure/static/sw.js b/src/chess_pressure/static/sw.js index f3987d9..8eecf68 100644 --- a/src/chess_pressure/static/sw.js +++ b/src/chess_pressure/static/sw.js @@ -7,7 +7,7 @@ * * Bump CACHE on every deploy so clients pick up new assets. */ -const CACHE = "chess-pressure-v26"; +const CACHE = "chess-pressure-v27"; // Same-origin app shell. Cached by canonical path; the fetch handler matches // with ignoreSearch so cache-busting query strings (?v=NN) still hit.