From 8d893085a1bdbd27ad06b302e16007f3603eb1ae Mon Sep 17 00:00:00 2001 From: jeremy-croff Date: Thu, 14 Mar 2024 18:46:09 -0500 Subject: [PATCH 1/3] fix(38362): add optional chain for stopasync video ref --- src/components/VideoPlayerContexts/PlaybackContext.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/VideoPlayerContexts/PlaybackContext.tsx b/src/components/VideoPlayerContexts/PlaybackContext.tsx index ae33a82fd0e7..d751f861711b 100644 --- a/src/components/VideoPlayerContexts/PlaybackContext.tsx +++ b/src/components/VideoPlayerContexts/PlaybackContext.tsx @@ -19,7 +19,7 @@ function PlaybackContextProvider({children}: ChildrenProps) { }, [currentVideoPlayerRef]); const stopVideo = useCallback(() => { - currentVideoPlayerRef.current?.stopAsync(); + currentVideoPlayerRef.current?.stopAsync?.(); }, [currentVideoPlayerRef]); const playVideo = useCallback(() => { From 9af6e46d20f1c2c1aa27c1df9b3cd48c2a07d02f Mon Sep 17 00:00:00 2001 From: jeremy-croff Date: Thu, 14 Mar 2024 19:08:36 -0500 Subject: [PATCH 2/3] fix(38362): revert all optional chaining --- .../VideoPlayerContexts/PlaybackContext.tsx | 12 ++++++------ .../VideoPlayerContexts/VideoPopoverMenuContext.tsx | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/components/VideoPlayerContexts/PlaybackContext.tsx b/src/components/VideoPlayerContexts/PlaybackContext.tsx index d751f861711b..92eb1960deef 100644 --- a/src/components/VideoPlayerContexts/PlaybackContext.tsx +++ b/src/components/VideoPlayerContexts/PlaybackContext.tsx @@ -15,25 +15,25 @@ function PlaybackContextProvider({children}: ChildrenProps) { const {currentReportID} = useCurrentReportID() ?? {}; const pauseVideo = useCallback(() => { - currentVideoPlayerRef.current?.setStatusAsync({shouldPlay: false}); + currentVideoPlayerRef?.current?.setStatusAsync?.({shouldPlay: false}); }, [currentVideoPlayerRef]); const stopVideo = useCallback(() => { - currentVideoPlayerRef.current?.stopAsync?.(); + currentVideoPlayerRef?.current?.stopAsync?.(); }, [currentVideoPlayerRef]); const playVideo = useCallback(() => { - currentVideoPlayerRef.current?.getStatusAsync().then((status) => { + currentVideoPlayerRef?.current?.getStatusAsync?.().then((status) => { const newStatus: AVPlaybackStatusToSet = {shouldPlay: true}; if ('durationMillis' in status && status.durationMillis === status.positionMillis) { newStatus.positionMillis = 0; } - currentVideoPlayerRef.current?.setStatusAsync(newStatus); + currentVideoPlayerRef?.current?.setStatusAsync(newStatus); }); }, [currentVideoPlayerRef]); const unloadVideo = useCallback(() => { - currentVideoPlayerRef.current?.unloadAsync(); + currentVideoPlayerRef?.current?.unloadAsync?.(); }, [currentVideoPlayerRef]); const updateCurrentlyPlayingURL = useCallback( @@ -61,7 +61,7 @@ function PlaybackContextProvider({children}: ChildrenProps) { const checkVideoPlaying = useCallback( (statusCallback: StatusCallback) => { - currentVideoPlayerRef.current?.getStatusAsync().then((status) => { + currentVideoPlayerRef?.current?.getStatusAsync?.().then((status) => { statusCallback('isPlaying' in status && status.isPlaying); }); }, diff --git a/src/components/VideoPlayerContexts/VideoPopoverMenuContext.tsx b/src/components/VideoPlayerContexts/VideoPopoverMenuContext.tsx index 0a53801683c3..d5c04a6b234d 100644 --- a/src/components/VideoPlayerContexts/VideoPopoverMenuContext.tsx +++ b/src/components/VideoPlayerContexts/VideoPopoverMenuContext.tsx @@ -22,7 +22,7 @@ function VideoPopoverMenuContextProvider({children}: ChildrenProps) { const updatePlaybackSpeed = useCallback( (speed: PlaybackSpeed) => { setCurrentPlaybackSpeed(speed); - currentVideoPlayerRef.current?.setStatusAsync({rate: speed}); + currentVideoPlayerRef?.current?.setStatusAsync?.({rate: speed}); }, [currentVideoPlayerRef], ); From 5c4a1c23bb0fb8903631deacdca7728a7ada98e1 Mon Sep 17 00:00:00 2001 From: jeremy-croff Date: Thu, 14 Mar 2024 19:14:17 -0500 Subject: [PATCH 3/3] fix(38362): remove optional chain for ref --- .../VideoPlayerContexts/PlaybackContext.tsx | 12 ++++++------ .../VideoPlayerContexts/VideoPopoverMenuContext.tsx | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/components/VideoPlayerContexts/PlaybackContext.tsx b/src/components/VideoPlayerContexts/PlaybackContext.tsx index 92eb1960deef..caad4ce5519b 100644 --- a/src/components/VideoPlayerContexts/PlaybackContext.tsx +++ b/src/components/VideoPlayerContexts/PlaybackContext.tsx @@ -15,25 +15,25 @@ function PlaybackContextProvider({children}: ChildrenProps) { const {currentReportID} = useCurrentReportID() ?? {}; const pauseVideo = useCallback(() => { - currentVideoPlayerRef?.current?.setStatusAsync?.({shouldPlay: false}); + currentVideoPlayerRef.current?.setStatusAsync?.({shouldPlay: false}); }, [currentVideoPlayerRef]); const stopVideo = useCallback(() => { - currentVideoPlayerRef?.current?.stopAsync?.(); + currentVideoPlayerRef.current?.stopAsync?.(); }, [currentVideoPlayerRef]); const playVideo = useCallback(() => { - currentVideoPlayerRef?.current?.getStatusAsync?.().then((status) => { + currentVideoPlayerRef.current?.getStatusAsync?.().then((status) => { const newStatus: AVPlaybackStatusToSet = {shouldPlay: true}; if ('durationMillis' in status && status.durationMillis === status.positionMillis) { newStatus.positionMillis = 0; } - currentVideoPlayerRef?.current?.setStatusAsync(newStatus); + currentVideoPlayerRef.current?.setStatusAsync(newStatus); }); }, [currentVideoPlayerRef]); const unloadVideo = useCallback(() => { - currentVideoPlayerRef?.current?.unloadAsync?.(); + currentVideoPlayerRef.current?.unloadAsync?.(); }, [currentVideoPlayerRef]); const updateCurrentlyPlayingURL = useCallback( @@ -61,7 +61,7 @@ function PlaybackContextProvider({children}: ChildrenProps) { const checkVideoPlaying = useCallback( (statusCallback: StatusCallback) => { - currentVideoPlayerRef?.current?.getStatusAsync?.().then((status) => { + currentVideoPlayerRef.current?.getStatusAsync?.().then((status) => { statusCallback('isPlaying' in status && status.isPlaying); }); }, diff --git a/src/components/VideoPlayerContexts/VideoPopoverMenuContext.tsx b/src/components/VideoPlayerContexts/VideoPopoverMenuContext.tsx index d5c04a6b234d..f953ed802623 100644 --- a/src/components/VideoPlayerContexts/VideoPopoverMenuContext.tsx +++ b/src/components/VideoPlayerContexts/VideoPopoverMenuContext.tsx @@ -22,7 +22,7 @@ function VideoPopoverMenuContextProvider({children}: ChildrenProps) { const updatePlaybackSpeed = useCallback( (speed: PlaybackSpeed) => { setCurrentPlaybackSpeed(speed); - currentVideoPlayerRef?.current?.setStatusAsync?.({rate: speed}); + currentVideoPlayerRef.current?.setStatusAsync?.({rate: speed}); }, [currentVideoPlayerRef], );