From f5886ab4fa8e4263539d67a2ca185cf54e471cf7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bojan=20Stefanovi=C4=87?= <5675392+bojanstef@users.noreply.github.com> Date: Fri, 19 Jun 2026 21:22:59 -0400 Subject: [PATCH] Fix video playback position reset to 0:00 on full-screen close (#1922) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit UniversalVideoGalleryItemNode.maybeStorePlaybackStatus persisted the playback position from every MediaPlayerStatus delivered by the throttled status subscription — including the teardown/reset status emitted when the full-screen player is dismissed (timestamp ~0, with a freshly incremented seekId). That status fell into the `else` branch and stored a position of 0.0, overwriting the real saved position on every close. So the stored "resume" point was always 0 and the video always restarted at 0:00. Persist only a genuine mid-video position; store the 0.0 "restart" sentinel only when the video is actually near the end; and leave any saved position untouched for timestamp <= 5s (which also covers the teardown reset that caused the bug). Co-Authored-By: Claude Opus 4.8 (1M context) --- .../Sources/Items/UniversalVideoGalleryItem.swift | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/submodules/GalleryUI/Sources/Items/UniversalVideoGalleryItem.swift b/submodules/GalleryUI/Sources/Items/UniversalVideoGalleryItem.swift index c21dab581d..184f9abbdc 100644 --- a/submodules/GalleryUI/Sources/Items/UniversalVideoGalleryItem.swift +++ b/submodules/GalleryUI/Sources/Items/UniversalVideoGalleryItem.swift @@ -2411,13 +2411,11 @@ final class UniversalVideoGalleryItemNode: ZoomableContentGalleryItemNode { shouldStorePlaybacksState = status.duration >= 20.0 if shouldStorePlaybacksState { - var timestamp: Double? if status.timestamp > 5.0 && status.timestamp < status.duration - 5.0 { - timestamp = status.timestamp - } else { - timestamp = 0.0 + item.storeMediaPlaybackState(message.id, status.timestamp, status.baseRate) + } else if status.timestamp >= status.duration - 5.0 { + item.storeMediaPlaybackState(message.id, 0.0, status.baseRate) } - item.storeMediaPlaybackState(message.id, timestamp, status.baseRate) } else { item.storeMediaPlaybackState(message.id, nil, status.baseRate) }