fix(#2789): fix fullgame duration for switch playlists

keep-around/b214ac7012ef42593bee62c207888a2593bc5a38
Andrei Dekterev 3 years ago
parent 1f5d372f55
commit 0fd427bbe7
  1. 15
      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' import debounce from 'lodash/debounce'
@ -19,6 +23,7 @@ const MATCH_PLAYLISTS_DELAY = 5000
export const useMatchData = (profile: MatchInfo) => { export const useMatchData = (profile: MatchInfo) => {
const { profileId: matchId, sportType } = usePageParams() const { profileId: matchId, sportType } = usePageParams()
const { chapters } = useMatchPopupStore() const { chapters } = useMatchPopupStore()
const [matchDuration, setMatchDuration] = useState(0)
const { const {
fetchMatchPlaylists, fetchMatchPlaylists,
handlePlaylistClick, handlePlaylistClick,
@ -32,7 +37,8 @@ export const useMatchData = (profile: MatchInfo) => {
() => debounce(fetchMatchPlaylists, MATCH_PLAYLISTS_DELAY), () => debounce(fetchMatchPlaylists, MATCH_PLAYLISTS_DELAY),
[fetchMatchPlaylists], [fetchMatchPlaylists],
) )
const fullMatchDuration = useDuration(chapters) / 1000 const chaptersDuration = useDuration(chapters) / 1000
const fullMatchDuration = matchDuration
useEffect(() => { useEffect(() => {
if (!profile) return if (!profile) return
fetchMatchPlaylists({ fetchMatchPlaylists({
@ -73,6 +79,11 @@ export const useMatchData = (profile: MatchInfo) => {
} }
}, [profile?.live, start, stop]) }, [profile?.live, start, stop])
useEffect(() => {
selectedPlaylist?.id === 'full_game' && setMatchDuration(chaptersDuration)
// eslint-disable-next-line
}, [profile, chaptersDuration])
return { return {
events, events,
handlePlaylistClick, handlePlaylistClick,

Loading…
Cancel
Save