diff --git a/Makefile b/Makefile index e663d6c5..15c2803a 100644 --- a/Makefile +++ b/Makefile @@ -73,7 +73,7 @@ build-g: clean build-h: clean REACT_APP_TYPE=ott \ - REACT_APP_ENV=staging \ + REACT_APP_ENV=production \ REACT_APP_CLIENT=insports \ REACT_APP_STAGE=test-h \ npm run build diff --git a/src/config/procedures.tsx b/src/config/procedures.tsx index de9aa619..9af152ff 100644 --- a/src/config/procedures.tsx +++ b/src/config/procedures.tsx @@ -3,7 +3,9 @@ export const PROCEDURES = { get_cities: 'get_cities', get_languages: 'get_languages', get_match_info: 'get_match_info', + get_match_plays: 'get_match_plays', get_match_subscriptions: 'get_match_subscriptions', + get_match_watch: 'get_match_watch', get_matches: 'get_matches', get_objects: 'get_objects', get_player_info: 'get_player_info', @@ -28,8 +30,6 @@ export const PROCEDURES = { get_view_user_match: 'get_view_user_match', landing_get_match_info: 'landing_get_match_info', lst_c_country: 'lst_c_country', - ott_match_events: 'ott_match_events', - ott_match_popup: 'ott_match_popup', ott_match_popup_actions: 'ott_match_popup_actions', ott_match_popup_player_playlist: 'ott_match_popup_player_playlist', param_lexical: 'param_lexical', diff --git a/src/features/AuthStore/helpers.tsx b/src/features/AuthStore/helpers.tsx index 50818c4f..f38a1480 100644 --- a/src/features/AuthStore/helpers.tsx +++ b/src/features/AuthStore/helpers.tsx @@ -52,7 +52,7 @@ const redirectUrl = () => { || Boolean(clientsForRedirect[client.name]) ): return `${window.origin}/redirect` - case (ENV === 'staging' || ENV === 'preproduction'): + case (ENV === 'staging' || ENV === 'preproduction' || ENV === 'production'): return `https://${stageENV}.insports.tv/redirect` default: return `https://${clientName}.tv/redirect` diff --git a/src/features/MatchPage/store/hooks/useMatchData.tsx b/src/features/MatchPage/store/hooks/useMatchData.tsx index 8a3255cd..6310fe94 100644 --- a/src/features/MatchPage/store/hooks/useMatchData.tsx +++ b/src/features/MatchPage/store/hooks/useMatchData.tsx @@ -1,11 +1,9 @@ import { useEffect, - useMemo, useState, + useCallback, } from 'react' -import debounce from 'lodash/debounce' - import type { MatchInfo } from 'requests/getMatchInfo' import { usePageParams, useInterval } from 'hooks' @@ -19,8 +17,7 @@ import { useMatchPlaylists } from './useMatchPlaylists' import { useEvents } from './useEvents' import { initialPlaylist } from './useSelectedPlaylist' -const MATCH_DATA_POLL_INTERVAL = 60000 -const MATCH_PLAYLISTS_DELAY = 5000 +const MATCH_DATA_POLL_INTERVAL = 5000 type UseMatchDataArgs = { matchProfile: MatchInfo, @@ -42,37 +39,38 @@ export const useMatchData = ({ matchProfile: profile, selectedTab }: UseMatchDat const { events, fetchMatchEvents } = useEvents() - const fetchPlaylistsDebounced = useMemo( - () => debounce(fetchMatchPlaylists, MATCH_PLAYLISTS_DELAY), - [fetchMatchPlaylists], - ) const chaptersDuration = useDuration(chapters) / 1000 const fullMatchDuration = matchDuration useEffect(() => { - if (!profile || (profile.live && Number(profile.c_match_calc_status) <= 1)) return + if (!profile || profile.live) return + fetchMatchPlaylists({ fullMatchDuration, id: matchId, sportType, }) fetchMatchEvents() + // eslint-disable-next-line react-hooks/exhaustive-deps }, [ - profile, + profile?.live, fullMatchDuration, matchId, sportType, - fetchMatchPlaylists, - fetchMatchEvents, ]) - const intervalCallback = () => { - fetchPlaylistsDebounced({ + const intervalCallback = useCallback(() => { + fetchMatchPlaylists({ fullMatchDuration, id: matchId, sportType, }) fetchMatchEvents() - } + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [ + fullMatchDuration, + matchId, + sportType, + ]) const { start, stop } = useInterval({ callback: intervalCallback, @@ -86,7 +84,7 @@ export const useMatchData = ({ matchProfile: profile, selectedTab }: UseMatchDat } else { stop() } - }, [profile?.live, profile?.c_match_calc_status, start, stop]) + }, [profile?.live, profile?.c_match_calc_status, start, stop, matchId]) useEffect(() => { selectedPlaylist?.id === FULL_GAME_KEY && setMatchDuration(chaptersDuration) diff --git a/src/features/MatchPage/store/hooks/useMatchPlaylists.tsx b/src/features/MatchPage/store/hooks/useMatchPlaylists.tsx index 21a05785..b5475f7d 100644 --- a/src/features/MatchPage/store/hooks/useMatchPlaylists.tsx +++ b/src/features/MatchPage/store/hooks/useMatchPlaylists.tsx @@ -67,7 +67,6 @@ export const useMatchPlaylists = ({ getMatchPlaylists({ fullMatchDuration, matchId: id, - selectedActions: [], sportType, }).then(fetchLexics) .then(buildPlaylists) diff --git a/src/features/MatchPopup/store/hooks/index.tsx b/src/features/MatchPopup/store/hooks/index.tsx index ec8107a2..df39d8c2 100644 --- a/src/features/MatchPopup/store/hooks/index.tsx +++ b/src/features/MatchPopup/store/hooks/index.tsx @@ -95,7 +95,6 @@ export const useMatchPopup = () => { getMatchPlaylists({ fullMatchDuration, matchId: id, - selectedActions: [], sportType, withFullMatchDuration, }).then(fetchLexics) diff --git a/src/hooks/useInterval.tsx b/src/hooks/useInterval.tsx index 01fa4ee0..eaf9cd9c 100644 --- a/src/hooks/useInterval.tsx +++ b/src/hooks/useInterval.tsx @@ -31,7 +31,7 @@ export const useInterval = ({ const id = setInterval(savedCallback.current, intervalDuration) return () => clearInterval(id) - }, [isRunning, intervalDuration]) + }, [isRunning, intervalDuration, callback]) return { start, stop } } diff --git a/src/requests/getMatchEvents.tsx b/src/requests/getMatchEvents.tsx index 22f2068c..87a09886 100644 --- a/src/requests/getMatchEvents.tsx +++ b/src/requests/getMatchEvents.tsx @@ -1,14 +1,10 @@ -import { - DATA_URL, - PROCEDURES, - -} from 'config' +import { STATS_API_URL, PROCEDURES } from 'config' import { Episode, Episodes } from 'requests' -import { callApi, getSportLexic } from 'helpers' +import { callApi } from 'helpers' -const proc = PROCEDURES.ott_match_events +const proc = PROCEDURES.get_match_plays type Args = { matchId: number, @@ -66,7 +62,8 @@ export const getMatchEvents = async ({ const config = { body: { params: { - _p_match_id: matchId, + match_id: matchId, + sport_id: sportType, }, proc, }, @@ -74,7 +71,7 @@ export const getMatchEvents = async ({ const response: Response = await callApi({ config, - url: `${DATA_URL}/${getSportLexic(sportType)}`, + url: `${STATS_API_URL}/data/stats`, }) if (!response?.data) return Promise.reject(response) diff --git a/src/requests/getMatchPlaylists.tsx b/src/requests/getMatchPlaylists.tsx index d45eef73..688c2267 100644 --- a/src/requests/getMatchPlaylists.tsx +++ b/src/requests/getMatchPlaylists.tsx @@ -1,18 +1,11 @@ -import isEmpty from 'lodash/isEmpty' +import { PROCEDURES, STATS_API_URL } from 'config' +import { callApi } from 'helpers' -import { - DATA_URL, - PROCEDURES, - -} from 'config' -import { callApi, getSportLexic } from 'helpers' - -const proc = PROCEDURES.ott_match_popup +const proc = PROCEDURES.get_match_watch type Args = { fullMatchDuration?: number, matchId: number, - selectedActions: Array, sportType: number, withFullMatchDuration?: boolean, } @@ -79,16 +72,13 @@ type Response = { export const getMatchPlaylists = async ({ fullMatchDuration, matchId, - selectedActions, sportType, }: Args): Promise => { - const actions = isEmpty(selectedActions) ? null : selectedActions - const config = { body: { params: { - _p_actions: actions, - _p_match_id: matchId, + match_id: matchId, + sport_id: sportType, }, proc, }, @@ -102,7 +92,7 @@ export const getMatchPlaylists = async ({ try { const playlist: Response = await callApi({ config, - url: `${DATA_URL}/${getSportLexic(sportType)}`, + url: `${STATS_API_URL}/data/stats`, }) if (playlist.data) { return { ...playlist.data, full_game }