diff --git a/src/features/MatchPage/store/hooks/useMatchData.tsx b/src/features/MatchPage/store/hooks/useMatchData.tsx index 54df0d61..b4b1ab20 100644 --- a/src/features/MatchPage/store/hooks/useMatchData.tsx +++ b/src/features/MatchPage/store/hooks/useMatchData.tsx @@ -1,4 +1,8 @@ -import { useEffect, useMemo } from 'react' +import { + useEffect, + useMemo, + useState, +} from 'react' import debounce from 'lodash/debounce' @@ -19,6 +23,7 @@ const MATCH_PLAYLISTS_DELAY = 5000 export const useMatchData = (profile: MatchInfo) => { const { profileId: matchId, sportType } = usePageParams() const { chapters } = useMatchPopupStore() + const [matchDuration, setMatchDuration] = useState(0) const { fetchMatchPlaylists, handlePlaylistClick, @@ -32,7 +37,8 @@ export const useMatchData = (profile: MatchInfo) => { () => debounce(fetchMatchPlaylists, MATCH_PLAYLISTS_DELAY), [fetchMatchPlaylists], ) - const fullMatchDuration = useDuration(chapters) / 1000 + const chaptersDuration = useDuration(chapters) / 1000 + const fullMatchDuration = matchDuration useEffect(() => { if (!profile) return fetchMatchPlaylists({ @@ -73,6 +79,11 @@ export const useMatchData = (profile: MatchInfo) => { } }, [profile?.live, start, stop]) + useEffect(() => { + selectedPlaylist?.id === 'full_game' && setMatchDuration(chaptersDuration) + // eslint-disable-next-line + }, [profile, chaptersDuration]) + return { events, handlePlaylistClick,