feat: remove a saved game & redirect on missing/deleted game (#20)
CI / build + unit + e2e (pull_request) Successful in 1m14s
CI / build + unit + e2e (pull_request) Successful in 1m14s
- DELETE /api/games/:id route + Db.delete() (404 when absent) - PresetPicker: per-saved-game trash button + confirm dialog (Cancel/Delete) - App: runDeleteGame; useSse onError -> goHome on 'deleted'/'not found' (a deleted/missing game now returns the live tab and any deep link home) - DeleteGameResponse in shared/protocol.ts; api.deleteGame() - unit test (Db.delete) + 2 e2e tests (home-screen delete; in-flight delete returns the active tab home and a fresh deep link lands on home) - version 0.7.0 -> 0.8.0 + changelog Fixes #20
This commit is contained in:
@@ -156,6 +156,17 @@ app.get('/api/games/:id/map', (req, res) => {
|
||||
res.json({ regions: buildRegionMap(game) });
|
||||
});
|
||||
|
||||
// Delete a saved game entirely. Fast, non-LLM. 404 if it doesn't exist; on
|
||||
// success broadcast an SSE `error` to any other open tab watching it so it
|
||||
// returns home (see the `event: error` handling in src/lib/sse.ts).
|
||||
app.delete('/api/games/:id', (req, res) => {
|
||||
const id = req.params.id;
|
||||
const removed = db.delete(id);
|
||||
if (!removed) return res.status(404).json({ error: 'game not found' });
|
||||
broadcast(id, 'error', { message: 'game deleted' });
|
||||
res.json({ deleted: true });
|
||||
});
|
||||
|
||||
// Queue a free-text player action onto the pending round. No LLM call and no
|
||||
// turn advance — the round is only committed (in one turn) by "Jump forward".
|
||||
app.post('/api/games/:id/action', (req, res) => {
|
||||
|
||||
Reference in New Issue
Block a user