|
|
|
|
@ -7,6 +7,7 @@ import isEmpty from 'lodash/isEmpty' |
|
|
|
|
|
|
|
|
|
import type { SportTypes } from 'config/sportTypes' |
|
|
|
|
|
|
|
|
|
import { MatchInfo } from 'requests/getMatchInfo' |
|
|
|
|
import { getMatchPlaylists } from 'requests/getMatchPlaylists' |
|
|
|
|
|
|
|
|
|
import type { Playlists } from 'features/MatchPage/types' |
|
|
|
|
@ -23,7 +24,7 @@ type ArgsFetchMatchPlaylists = { |
|
|
|
|
|
|
|
|
|
const initialPlaylists = buildPlaylists(null) |
|
|
|
|
|
|
|
|
|
export const useMatchPlaylists = () => { |
|
|
|
|
export const useMatchPlaylists = (profile: MatchInfo) => { |
|
|
|
|
const [matchPlaylists, setMatchPlaylists] = useState<Playlists>(initialPlaylists) |
|
|
|
|
|
|
|
|
|
const { fetchLexics } = usePlaylistLexics() |
|
|
|
|
@ -35,13 +36,13 @@ export const useMatchPlaylists = () => { |
|
|
|
|
|
|
|
|
|
const setInitialSeletedPlaylist = useCallback((playlists: Playlists) => { |
|
|
|
|
setSelectedPlaylist((playlist) => { |
|
|
|
|
if (!playlist && !isEmpty(playlists.match)) { |
|
|
|
|
if ((!playlist && !isEmpty(playlists.match)) || profile?.live) { |
|
|
|
|
return playlists.match[0] |
|
|
|
|
} |
|
|
|
|
return playlist |
|
|
|
|
}) |
|
|
|
|
return playlists |
|
|
|
|
}, [setSelectedPlaylist]) |
|
|
|
|
}, [profile, setSelectedPlaylist]) |
|
|
|
|
|
|
|
|
|
const fetchMatchPlaylists = useCallback(({ |
|
|
|
|
fullMatchDuration, |
|
|
|
|
|