From 0eec23a20e87db96592c79310f65ae6fcf5804c6 Mon Sep 17 00:00:00 2001 From: jeremy-croff Date: Tue, 27 Feb 2024 19:36:24 -0600 Subject: [PATCH 1/2] fix(37142): unmount video ref when attachment closes --- src/components/Attachments/AttachmentView/index.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/components/Attachments/AttachmentView/index.js b/src/components/Attachments/AttachmentView/index.js index c871628f65e7..8443e167b499 100755 --- a/src/components/Attachments/AttachmentView/index.js +++ b/src/components/Attachments/AttachmentView/index.js @@ -95,7 +95,7 @@ function AttachmentView({ isHovered, optionalVideoDuration, }) { - const {updateCurrentlyPlayingURL} = usePlaybackContext(); + const {updateCurrentlyPlayingURL, currentVideoPlayerRef} = usePlaybackContext(); const theme = useTheme(); const styles = useThemeStyles(); const StyleUtils = useStyleUtils(); @@ -109,6 +109,16 @@ function AttachmentView({ updateCurrentlyPlayingURL(isVideo ? source : null); }, [isFocused, isVideo, source, updateCurrentlyPlayingURL, file, isUsedInAttachmentModal]); + useEffect( + () => () => { + if (!isVideo) { + return; + } + currentVideoPlayerRef.current = null; + }, + [isVideo, currentVideoPlayerRef], + ); + const [imageError, setImageError] = useState(false); useNetwork({onReconnect: () => setImageError(false)}); From cb302a8591a5756820ffa68de732b9956a083ebc Mon Sep 17 00:00:00 2001 From: jeremy-croff Date: Mon, 4 Mar 2024 11:57:25 -0600 Subject: [PATCH 2/2] fix(37142): Add comments --- src/components/Attachments/AttachmentView/index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/Attachments/AttachmentView/index.js b/src/components/Attachments/AttachmentView/index.js index 8443e167b499..3e078d28e7ef 100755 --- a/src/components/Attachments/AttachmentView/index.js +++ b/src/components/Attachments/AttachmentView/index.js @@ -109,6 +109,7 @@ function AttachmentView({ updateCurrentlyPlayingURL(isVideo ? source : null); }, [isFocused, isVideo, source, updateCurrentlyPlayingURL, file, isUsedInAttachmentModal]); + // This should ensure we clean up any video references when closing the attachment modal as these only existed here in memory during attachment preview. useEffect( () => () => { if (!isVideo) {