From 7f1855f77f227a29788650bc75cce04699a652d8 Mon Sep 17 00:00:00 2001 From: Andrei Dekterev Date: Thu, 8 Sep 2022 14:44:44 +0400 Subject: [PATCH] fix(#2789): fix calculate duration for btn fullgame in matchpage --- src/features/MatchPage/store/hooks/useMatchData.tsx | 9 +++++---- src/features/MatchPopup/store/hooks/index.tsx | 1 + 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/features/MatchPage/store/hooks/useMatchData.tsx b/src/features/MatchPage/store/hooks/useMatchData.tsx index 4696407a..54df0d61 100644 --- a/src/features/MatchPage/store/hooks/useMatchData.tsx +++ b/src/features/MatchPage/store/hooks/useMatchData.tsx @@ -7,7 +7,9 @@ import { MatchInfo } from 'requests/getMatchInfo' import { usePageParams } from 'hooks/usePageParams' import { useInterval } from 'hooks/useInterval' -import { calculateDuration } from '../../helpers/fullMatchDuration' +import { useDuration } from 'features/MultiSourcePlayer/hooks/useDuration' +import { useMatchPopupStore } from 'features/MatchPopup' + import { useMatchPlaylists } from './useMatchPlaylists' import { useEvents } from './useEvents' @@ -16,6 +18,7 @@ const MATCH_PLAYLISTS_DELAY = 5000 export const useMatchData = (profile: MatchInfo) => { const { profileId: matchId, sportType } = usePageParams() + const { chapters } = useMatchPopupStore() const { fetchMatchPlaylists, handlePlaylistClick, @@ -29,9 +32,7 @@ export const useMatchData = (profile: MatchInfo) => { () => debounce(fetchMatchPlaylists, MATCH_PLAYLISTS_DELAY), [fetchMatchPlaylists], ) - - const fullMatchDuration = useMemo(() => calculateDuration(profile), [profile]) - + const fullMatchDuration = useDuration(chapters) / 1000 useEffect(() => { if (!profile) return fetchMatchPlaylists({ diff --git a/src/features/MatchPopup/store/hooks/index.tsx b/src/features/MatchPopup/store/hooks/index.tsx index a563f377..b5ac41e7 100644 --- a/src/features/MatchPopup/store/hooks/index.tsx +++ b/src/features/MatchPopup/store/hooks/index.tsx @@ -115,6 +115,7 @@ export const useMatchPopup = () => { } return { actions, + chapters, closePopup, fetchMatchPlaylists, fetchSportActions,