diff --git a/src/features/MatchPage/store/hooks/useMatchData.tsx b/src/features/MatchPage/store/hooks/useMatchData.tsx index ff287d89..4cee0488 100644 --- a/src/features/MatchPage/store/hooks/useMatchData.tsx +++ b/src/features/MatchPage/store/hooks/useMatchData.tsx @@ -31,7 +31,7 @@ export const useMatchData = (profile: MatchInfo) => { selectedPlaylist, setFullMatchPlaylistDuration, setSelectedPlaylist, - } = useMatchPlaylists() + } = useMatchPlaylists(profile) const { events, fetchMatchEvents } = useEvents() const fetchPlaylistsDebounced = useMemo( diff --git a/src/features/MatchPage/store/hooks/useMatchPlaylists.tsx b/src/features/MatchPage/store/hooks/useMatchPlaylists.tsx index c987b509..a720f362 100644 --- a/src/features/MatchPage/store/hooks/useMatchPlaylists.tsx +++ b/src/features/MatchPage/store/hooks/useMatchPlaylists.tsx @@ -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(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, diff --git a/src/features/StreamPlayer/hooks/index.tsx b/src/features/StreamPlayer/hooks/index.tsx index 92fd8ab6..91ef416f 100644 --- a/src/features/StreamPlayer/hooks/index.tsx +++ b/src/features/StreamPlayer/hooks/index.tsx @@ -87,7 +87,6 @@ export const useVideoPlayer = ({ playNextEpisode, selectedPlaylist, } = useLiveMatch() - const { lang } = useLexicsStore() const { url } = chapters[0] ?? { url: '' } @@ -310,6 +309,16 @@ export const useVideoPlayer = ({ const regURL = /\d{6,20}/gi + useEffect(() => { + if (isLive) { + setPlayerState({ + ...initialState, + chapters: chaptersProps, + }) + } + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [isLive]) + useEffect(() => { if (((isLive || chapters[0].duration === chaptersProps[0].duration) && chapters[0]?.endOffsetMs === chaptersProps[0]?.endOffsetMs diff --git a/src/features/StreamPlayer/hooks/useHlsPlayer.tsx b/src/features/StreamPlayer/hooks/useHlsPlayer.tsx index 1463d086..34c995c4 100644 --- a/src/features/StreamPlayer/hooks/useHlsPlayer.tsx +++ b/src/features/StreamPlayer/hooks/useHlsPlayer.tsx @@ -18,7 +18,8 @@ export const useHlsPlayer = (src: string, resumeFrom?: number) => { newStreamConfig.startPosition = resumeFrom } return new Hls(newStreamConfig) - }, [resumeFrom]) + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [resumeFrom, src]) const videoRef = useRef(null)