feat(custom): store the reader's games and events, and back them up

Adds the two localStorage stores behind PRD F13 and joins their events to the
feed's in App, so they sort, filter, focus, expire and tick through exactly the
same code paths rather than a parallel set.

Three decisions worth naming:

- Export carries customGames and customEvents. These exist in one browser and
  nowhere else — not in the feed, not on a server — so an export without them
  would be a backup that loses the half the reader typed. Import merges by id
  like every other set and never removes.
- A date is read in the reader's timezone, and a bare end date means the end of
  that day. Someone who types 20 Aug means the 20th where they are; the feed's
  00:00Z day boundaries are a parser declining to guess a time the source never
  printed, which is a different situation from being told directly.
- An impossible date is refused rather than rolled over, because Date.parse
  turns 30 February into 2 March and a silently shifted date is the failure this
  product exists to prevent.

Deleting a game is refused while it still holds events, and deleting an event
leaves its marks and logged days alone — reaching into three stores on one tap
is how a misclick costs somebody a streak.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
This commit is contained in:
Lucas Winther
2026-08-17 18:19:59 +02:00
co-authored by Claude Opus 5
parent 3702ee7a4c
commit d046758671
4 changed files with 386 additions and 23 deletions
+10
View File
@@ -25,6 +25,16 @@ export const KEYS = {
daily: `${NS}:daily`,
ignored: `${NS}:ignored`,
prefs: `${NS}:prefs`,
/**
* Games and events the reader entered themselves (PRD F13).
*
* Two keys rather than one because they have different lifetimes: a game
* outlives the events in it, and deleting one is refused while the other
* still references it. Like everything else here, this is the only copy —
* there is no server that has ever seen it.
*/
customGames: `${NS}:customGames`,
customEvents: `${NS}:customEvents`,
} as const;
/**