Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion src/components/Attachments/AttachmentView/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ function AttachmentView({
isHovered,
optionalVideoDuration,
}) {
const {updateCurrentlyPlayingURL} = usePlaybackContext();
const {updateCurrentlyPlayingURL, currentVideoPlayerRef} = usePlaybackContext();
const theme = useTheme();
const styles = useThemeStyles();
const StyleUtils = useStyleUtils();
Expand All @@ -109,6 +109,17 @@ 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) {
return;
}
currentVideoPlayerRef.current = null;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a comment explaining why we need this? Here or above useEffect but it would be good so people understands it

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done, thanks @pecanoro

},
[isVideo, currentVideoPlayerRef],
);

const [imageError, setImageError] = useState(false);

useNetwork({onReconnect: () => setImageError(false)});
Expand Down