From 6832c273cd7a4114906359d04529d295205e829f Mon Sep 17 00:00:00 2001 From: talksik Date: Thu, 30 Apr 2026 16:39:23 -0700 Subject: [PATCH] fix: prevent restart playback after transcoding completion Closes #201 --- .../features/particles/media-particle-view.tsx | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/js/desktop/src/features/particles/media-particle-view.tsx b/js/desktop/src/features/particles/media-particle-view.tsx index 2efad22..21ba7c3 100644 --- a/js/desktop/src/features/particles/media-particle-view.tsx +++ b/js/desktop/src/features/particles/media-particle-view.tsx @@ -35,10 +35,20 @@ export const MediaParticleView = forwardRef src would restart + // playback from 0. Keep whatever we picked first; the original plays fine in + // Electron, and the transcoded variant will be picked up on the next view. + const pickedSourceRef = useRef<{ id: string; objectId: string; mime: string } | null>(null); + if (pickedSourceRef.current?.id !== particle.id) { + pickedSourceRef.current = { + id: particle.id, + objectId: particle.properties.transcoded_object_id ?? particle.properties.object_id, + mime: particle.properties.transcoded_mime_type ?? particle.properties.mime_type, + }; + } + const activeObjectId = pickedSourceRef.current.objectId; + const activeMime = pickedSourceRef.current.mime; const { data: url, error } = useDownloadUrl(activeObjectId); const { attachments } = useParticleAttachments(streamPath, particle.id);