From b11c83feed2eca1e277bd85fd98a12d37d8eb037 Mon Sep 17 00:00:00 2001 From: Kamil Owczarz Date: Tue, 20 Feb 2024 16:59:36 +0100 Subject: [PATCH 1/2] Fix crashing on video attachment preview interactions --- src/components/VideoPlayerContexts/PlaybackContext.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/components/VideoPlayerContexts/PlaybackContext.js b/src/components/VideoPlayerContexts/PlaybackContext.js index b77068f3aea2d..3856bbaa83e29 100644 --- a/src/components/VideoPlayerContexts/PlaybackContext.js +++ b/src/components/VideoPlayerContexts/PlaybackContext.js @@ -67,7 +67,8 @@ function PlaybackContextProvider({children}) { const checkVideoPlaying = useCallback( (statusCallback) => { - currentVideoPlayerRef.current.getStatusAsync().then((status) => { + // eslint-disable-next-line es/no-optional-chaining + currentVideoPlayerRef.current?.getStatusAsync?.().then((status) => { statusCallback(status.isPlaying); }); }, From fd72a5f1c9994524617d7d740b97400e6a60de82 Mon Sep 17 00:00:00 2001 From: Kamil Owczarz Date: Thu, 22 Feb 2024 16:17:44 +0100 Subject: [PATCH 2/2] Cleanup --- src/components/VideoPlayerContexts/PlaybackContext.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/components/VideoPlayerContexts/PlaybackContext.js b/src/components/VideoPlayerContexts/PlaybackContext.js index 3856bbaa83e29..8cf09f81c6142 100644 --- a/src/components/VideoPlayerContexts/PlaybackContext.js +++ b/src/components/VideoPlayerContexts/PlaybackContext.js @@ -67,8 +67,10 @@ function PlaybackContextProvider({children}) { const checkVideoPlaying = useCallback( (statusCallback) => { - // eslint-disable-next-line es/no-optional-chaining - currentVideoPlayerRef.current?.getStatusAsync?.().then((status) => { + if (!(currentVideoPlayerRef && currentVideoPlayerRef.current && currentVideoPlayerRef.current.getStatusAsync)) { + return; + } + currentVideoPlayerRef.current.getStatusAsync().then((status) => { statusCallback(status.isPlaying); }); },