fix(stats): fix data loss and error handling in anime merge/move

- flush pending telemetry before merge/move so in-progress session time isn't dropped from lifetime totals
- repoint subtitle lines by video_id instead of anime_id so lines recorded before the async title parse assigns a link aren't stranded
- stop absorbing metadata into the target when moving an episode out of an emptied entry (a move isn't a same-show claim)
- return 404 only for missing episode/target, not storage failures; return 404 when a merge folds nothing
- keep AnimeMergeDialog open while a merge is in flight instead of letting dismiss race the request
- surface library load failures in LibraryEntryPicker instead of showing an empty list
This commit is contained in:
2026-08-10 23:06:00 -07:00
parent 9c503fc67d
commit 5abc3b84f4
9 changed files with 164 additions and 17 deletions
@@ -822,11 +822,18 @@ export class ImmersionTrackerService {
if (pendingVideoId !== undefined) {
await this.pendingAnimeMetadataUpdates.get(pendingVideoId);
}
// Both of these rebuild the lifetime summaries, which recompute from the
// database: queued telemetry has to land first or the active session's
// watch time is dropped from the merged totals.
this.flushTelemetry(true);
this.flushNow();
return mergeAnimeRecords(this.db, targetAnimeId, sourceAnimeIds);
}
async moveVideoToAnime(videoId: number, targetAnimeId: number): Promise<VideoMoveSummary> {
await this.pendingAnimeMetadataUpdates.get(videoId);
this.flushTelemetry(true);
this.flushNow();
return moveVideoToAnimeQuery(this.db, videoId, targetAnimeId);
}