From 70bfcf0b8635102ebd8d2b80fbeea6db391f2fde Mon Sep 17 00:00:00 2001 From: Jacob Date: Fri, 31 May 2024 01:33:38 +0300 Subject: [PATCH 1/2] fix issue --- src/components/VideoPlayer/BaseVideoPlayer.tsx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/components/VideoPlayer/BaseVideoPlayer.tsx b/src/components/VideoPlayer/BaseVideoPlayer.tsx index bc7c32729c5a..cda67794550e 100644 --- a/src/components/VideoPlayer/BaseVideoPlayer.tsx +++ b/src/components/VideoPlayer/BaseVideoPlayer.tsx @@ -245,11 +245,14 @@ function BaseVideoPlayer({ ); // update shared video elements useEffect(() => { - if (shouldUseSharedVideoElement || url !== currentlyPlayingURL || isFullScreenRef.current) { + if (shouldUseSharedVideoElement || url !== currentlyPlayingURL) { return; } - shareVideoPlayerElements(videoPlayerRef.current, videoPlayerElementParentRef.current, videoPlayerElementRef.current, isUploading); - }, [currentlyPlayingURL, shouldUseSharedVideoElement, shareVideoPlayerElements, url, isUploading, isFullScreenRef]); + shareVideoPlayerElements(videoPlayerRef.current, videoPlayerElementParentRef.current, videoPlayerElementRef.current, isUploading || isFullScreenRef.current); + + // don't include `isFullScreenRef.current` in dependency array as we don't have to update shared video elements when it is changed + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [currentlyPlayingURL, shouldUseSharedVideoElement, shareVideoPlayerElements, url, isUploading]); // append shared video element to new parent (used for example in attachment modal) useEffect(() => { From 82c3c1833ac4d6f0b4bbb2408c151779032f7c84 Mon Sep 17 00:00:00 2001 From: moon Date: Fri, 7 Jun 2024 03:23:23 +0300 Subject: [PATCH 2/2] fix issues --- src/components/VideoPlayer/BaseVideoPlayer.tsx | 5 +---- src/components/VideoPlayerContexts/PlaybackContext.tsx | 4 ++-- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/components/VideoPlayer/BaseVideoPlayer.tsx b/src/components/VideoPlayer/BaseVideoPlayer.tsx index cda67794550e..8230f9132d00 100644 --- a/src/components/VideoPlayer/BaseVideoPlayer.tsx +++ b/src/components/VideoPlayer/BaseVideoPlayer.tsx @@ -249,10 +249,7 @@ function BaseVideoPlayer({ return; } shareVideoPlayerElements(videoPlayerRef.current, videoPlayerElementParentRef.current, videoPlayerElementRef.current, isUploading || isFullScreenRef.current); - - // don't include `isFullScreenRef.current` in dependency array as we don't have to update shared video elements when it is changed - // eslint-disable-next-line react-hooks/exhaustive-deps - }, [currentlyPlayingURL, shouldUseSharedVideoElement, shareVideoPlayerElements, url, isUploading]); + }, [currentlyPlayingURL, shouldUseSharedVideoElement, shareVideoPlayerElements, url, isUploading, isFullScreenRef]); // append shared video element to new parent (used for example in attachment modal) useEffect(() => { diff --git a/src/components/VideoPlayerContexts/PlaybackContext.tsx b/src/components/VideoPlayerContexts/PlaybackContext.tsx index 499dd2b07f67..0e5e7f993eea 100644 --- a/src/components/VideoPlayerContexts/PlaybackContext.tsx +++ b/src/components/VideoPlayerContexts/PlaybackContext.tsx @@ -51,12 +51,12 @@ function PlaybackContextProvider({children}: ChildrenProps) { ); const shareVideoPlayerElements = useCallback( - (ref: VideoWithOnFullScreenUpdate | null, parent: View | HTMLDivElement | null, child: View | HTMLDivElement | null, isUploading: boolean) => { + (ref: VideoWithOnFullScreenUpdate | null, parent: View | HTMLDivElement | null, child: View | HTMLDivElement | null, shouldNotAutoPlay: boolean) => { currentVideoPlayerRef.current = ref; setOriginalParent(parent); setSharedElement(child); // Prevents autoplay when uploading the attachment - if (!isUploading) { + if (!shouldNotAutoPlay) { playVideo(); } },