Fix M3: extract shared recordCompletion() for download-done side-effects
The completion side-effect (add to history unless private + markDownloaded on
the source MediaItem) was duplicated in applyEvent('done') and the preview
fake-ticker, and had already drifted (the preview copy omitted formatId/
formatHasAudio). Extracted one recordCompletion(item) helper that both call.
Also tightened a latent bug: the old applyEvent ran markDownloaded for any
'done' event with a mediaItemId, even when the item was canceled (the reducer
keeps canceled items as 'canceled'). recordCompletion now runs only when
status === 'completed', so a canceled collection item is no longer wrongly
marked downloaded (and will be retried on the next re-sync).
typecheck + 242 tests + eslint green.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
+1
-1
@@ -223,7 +223,7 @@ token system + shared primitives (UI/SIMP — high value, larger effort) · i18n
|
||||
`history.ts`/`errorlog.ts`/`templates.ts` reimplement it inline.
|
||||
- [x] **M2 — Remove dead code: `getDefaultFolder` / `download:default-folder`** (channel +
|
||||
preload + handler + mock, zero callers).
|
||||
- [ ] **M3 — Remove duplicated completion side-effect in `store/downloads.ts`** (history write +
|
||||
- [x] **M3 — Remove duplicated completion side-effect in `store/downloads.ts`** (history write +
|
||||
`markDownloaded` in both `applyEvent('done')` and the preview ticker). Subsumed by C2.
|
||||
- [ ] **M4 — Decide queue persistence explicitly.** Scheduler/queue is renderer-memory only;
|
||||
`saved`/scheduled items don't survive a quit. Persist or document as a non-goal in code.
|
||||
|
||||
Reference in New Issue
Block a user