From 6bdcd5141681b7b4a4aa8f46fdb285acbadc889a Mon Sep 17 00:00:00 2001 From: Arkadiusz Fal Date: Sun, 6 Sep 2026 23:12:13 +0200 Subject: [PATCH] Let a replay resume only the watch it started --- Yattee/Services/Player/PlayerService.swift | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Yattee/Services/Player/PlayerService.swift b/Yattee/Services/Player/PlayerService.swift index e9fd89d3..bc30f5ea 100644 --- a/Yattee/Services/Player/PlayerService.swift +++ b/Yattee/Services/Player/PlayerService.swift @@ -677,7 +677,8 @@ final class PlayerService { /// account's history again — which is what moves it back to the front. /// Seeking to the start mid-video is not this, and does not pass here. func replayCurrentVideo() async { - if let video = state.currentVideo { + let video = state.currentVideo + if let video { watchHistorySyncService?.beginSession(video: video) } @@ -690,6 +691,14 @@ final class PlayerService { videoEndedNaturally = false await seek(to: 0) + + // The seek is awaited, and the player can have moved on while it ran: + // stopped, or already playing something else. Only the replay that is + // still the current watch may resume playback and arm the save timer — + // otherwise this would unpause a video the user paused, or time saves + // for a watch that is not this one. + guard let video, state.currentVideo?.id == video.id else { return } + resume() startProgressSaveTimer() }