Skip to content

Commit

Permalink
dont reset video player when reportID was previously empty
Browse files Browse the repository at this point in the history
  • Loading branch information
bernhardoj committed Aug 6, 2024
1 parent 4ed343b commit 6bd2921
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/components/VideoPlayerContexts/PlaybackContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import React, {useCallback, useContext, useEffect, useMemo, useRef, useState} fr
import type {View} from 'react-native';
import type {VideoWithOnFullScreenUpdate} from '@components/VideoPlayer/types';
import useCurrentReportID from '@hooks/useCurrentReportID';
import usePrevious from '@hooks/usePrevious';
import type ChildrenProps from '@src/types/utils/ChildrenProps';
import type {PlaybackContext, StatusCallback} from './types';

Expand All @@ -15,6 +16,7 @@ function PlaybackContextProvider({children}: ChildrenProps) {
const [originalParent, setOriginalParent] = useState<View | HTMLDivElement | null>(null);
const currentVideoPlayerRef = useRef<VideoWithOnFullScreenUpdate | null>(null);
const {currentReportID} = useCurrentReportID() ?? {};
const prevCurrentReportID = usePrevious(currentReportID);
const videoResumeTryNumberRef = useRef<number>(0);
const playVideoPromiseRef = useRef<Promise<AVPlaybackStatus>>();

Expand Down Expand Up @@ -85,7 +87,7 @@ function PlaybackContextProvider({children}: ChildrenProps) {
}, [stopVideo, unloadVideo]);

useEffect(() => {
if (!currentReportID) {
if (!currentReportID || !prevCurrentReportID) {
return;
}
resetVideoPlayerData();
Expand Down

0 comments on commit 6bd2921

Please sign in to comment.