From 0fd427bbe73e213ae64f727f72f84522b8d99a81 Mon Sep 17 00:00:00 2001 From: Andrei Dekterev Date: Mon, 12 Sep 2022 18:40:36 +0400 Subject: [PATCH] fix(#2789): fix fullgame duration for switch playlists --- .../MatchPage/store/hooks/useMatchData.tsx | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) 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,