@@ -11,7 +11,6 @@ import AttachmentOfflineIndicator from '@components/AttachmentOfflineIndicator';
11
11
import FullScreenLoadingIndicator from '@components/FullscreenLoadingIndicator' ;
12
12
import Hoverable from '@components/Hoverable' ;
13
13
import PressableWithoutFeedback from '@components/Pressable/PressableWithoutFeedback' ;
14
- import { useSearchContext } from '@components/Search/SearchContext' ;
15
14
import { useFullScreenContext } from '@components/VideoPlayerContexts/FullScreenContext' ;
16
15
import { usePlaybackContext } from '@components/VideoPlayerContexts/PlaybackContext' ;
17
16
import type { PlaybackSpeed } from '@components/VideoPlayerContexts/types' ;
@@ -65,10 +64,9 @@ function BaseVideoPlayer({
65
64
originalParent,
66
65
shareVideoPlayerElements,
67
66
currentVideoPlayerRef,
68
- updateCurrentlyPlayingURL ,
67
+ updateCurrentURLAndReportID ,
69
68
videoResumeTryNumberRef,
70
69
setCurrentlyPlayingURL,
71
- currentlyPlayingURLReportID,
72
70
} = usePlaybackContext ( ) ;
73
71
const { isFullScreenRef} = useFullScreenContext ( ) ;
74
72
const { isOffline} = useNetwork ( ) ;
@@ -107,19 +105,18 @@ function BaseVideoPlayer({
107
105
const { videoPopoverMenuPlayerRef, currentPlaybackSpeed, setCurrentPlaybackSpeed, setSource : setPopoverMenuSource } = useVideoPopoverMenuContext ( ) ;
108
106
const { source} = videoPopoverMenuPlayerRef . current ?. props ?? { } ;
109
107
const shouldUseNewRate = typeof source === 'number' || ! source || source . uri !== sourceURL ;
110
- const { isOnSearch} = useSearchContext ( ) ;
111
108
112
109
const togglePlayCurrentVideo = useCallback ( ( ) => {
113
110
setIsEnded ( false ) ;
114
111
videoResumeTryNumberRef . current = 0 ;
115
112
if ( ! isCurrentlyURLSet ) {
116
- updateCurrentlyPlayingURL ( url ) ;
113
+ updateCurrentURLAndReportID ( url , reportID ) ;
117
114
} else if ( isPlaying ) {
118
115
pauseVideo ( ) ;
119
116
} else {
120
117
playVideo ( ) ;
121
118
}
122
- } , [ isCurrentlyURLSet , isPlaying , pauseVideo , playVideo , updateCurrentlyPlayingURL , url , videoResumeTryNumberRef ] ) ;
119
+ } , [ isCurrentlyURLSet , isPlaying , pauseVideo , playVideo , reportID , updateCurrentURLAndReportID , url , videoResumeTryNumberRef ] ) ;
123
120
124
121
const hideControl = useCallback ( ( ) => {
125
122
if ( isEnded ) {
@@ -355,18 +352,15 @@ function BaseVideoPlayer({
355
352
356
353
// update shared video elements
357
354
useEffect ( ( ) => {
358
- // in search page, we don't have active report id, so comparing reportID is not necessary
359
- if ( shouldUseSharedVideoElement || url !== currentlyPlayingURL || ( reportID !== currentlyPlayingURLReportID && ! isOnSearch ) ) {
360
- return ;
361
- }
362
355
// On mobile safari, we need to auto-play when sharing video element here
363
356
shareVideoPlayerElements (
364
357
videoPlayerRef . current ,
365
358
videoPlayerElementParentRef . current ,
366
359
videoPlayerElementRef . current ,
367
360
isUploading || isFullScreenRef . current || ( ! isReadyForDisplayRef . current && ! isMobileSafari ( ) ) ,
361
+ { shouldUseSharedVideoElement, url, reportID} ,
368
362
) ;
369
- } , [ currentlyPlayingURL , shouldUseSharedVideoElement , shareVideoPlayerElements , url , isUploading , isFullScreenRef , reportID , currentlyPlayingURLReportID , isOnSearch ] ) ;
363
+ } , [ currentlyPlayingURL , shouldUseSharedVideoElement , shareVideoPlayerElements , url , isUploading , isFullScreenRef , reportID ] ) ;
370
364
371
365
// Call bindFunctions() through the refs to avoid adding it to the dependency array of the DOM mutation effect, as doing so would change the DOM when the functions update.
372
366
const bindFunctionsRef = useRef < ( ( ) => void ) | null > ( null ) ;
@@ -413,14 +407,14 @@ function BaseVideoPlayer({
413
407
}
414
408
newParentRef . childNodes [ 0 ] ?. remove ( ) ;
415
409
} ;
416
- } , [ currentVideoPlayerRef , currentlyPlayingURL , currentlyPlayingURLReportID , isFullScreenRef , originalParent , reportID , sharedElement , shouldUseSharedVideoElement , url ] ) ;
410
+ } , [ currentVideoPlayerRef , currentlyPlayingURL , isFullScreenRef , originalParent , reportID , sharedElement , shouldUseSharedVideoElement , url ] ) ;
417
411
418
412
useEffect ( ( ) => {
419
413
if ( ! shouldPlay ) {
420
414
return ;
421
415
}
422
- updateCurrentlyPlayingURL ( url ) ;
423
- } , [ shouldPlay , updateCurrentlyPlayingURL , url ] ) ;
416
+ updateCurrentURLAndReportID ( url , reportID ) ;
417
+ } , [ reportID , shouldPlay , updateCurrentURLAndReportID , url ] ) ;
424
418
425
419
useEffect ( ( ) => {
426
420
videoPlayerRef . current ?. setStatusAsync ( { isMuted : true } ) ;
@@ -531,6 +525,7 @@ function BaseVideoPlayer({
531
525
togglePlayCurrentVideo = { togglePlayCurrentVideo }
532
526
controlsStatus = { controlStatusState }
533
527
showPopoverMenu = { showPopoverMenu }
528
+ reportID = { reportID }
534
529
/>
535
530
) }
536
531
</ View >
0 commit comments