From dd6582f613fa522a029d1fd3f3aee3fe86e18d33 Mon Sep 17 00:00:00 2001 From: Andrei Dekterev Date: Sat, 5 Mar 2022 15:18:39 +0700 Subject: [PATCH] feat(#2246): add loop requests for getmatchinfo in live --- Makefile | 2 +- src/features/AuthStore/helpers.tsx | 2 +- src/features/MatchPage/hooks/useMatchProfile.tsx | 12 ++++++++++++ .../components/YoutubePlayer/index.tsx | 8 ++++++-- src/features/StreamPlayer/hooks/index.tsx | 15 +++++++++++++++ 5 files changed, 35 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 4b467971..d1ff9828 100644 --- a/Makefile +++ b/Makefile @@ -88,7 +88,7 @@ b-stage: build rsync -zavP --delete-before build/ -e 'ssh -p 666' ott-staging@staging.instat.tv:/usr/local/www/ott-staging/b-wwwroot/ c-stage: build - rsync -zavP --delete-before build/ -e 'ssh -p 666' ott-staging@staging.instat.tv:/usr/local/www/ott-staging/c-wwwroot/ + rsync -zavP --delete-before build/ -e 'ssh -p 666' ott-staging@10.0.3.8:/usr/local/www/ott-staging/c-wwwroot/ d-stage: build rsync -zavP --delete-before build/ -e 'ssh -p 666' ott-staging@staging.instat.tv:/usr/local/www/ott-staging/d-wwwroot/ diff --git a/src/features/AuthStore/helpers.tsx b/src/features/AuthStore/helpers.tsx index 35eeabf8..48893795 100644 --- a/src/features/AuthStore/helpers.tsx +++ b/src/features/AuthStore/helpers.tsx @@ -24,7 +24,7 @@ const redirectUrl = () => { return `${window.origin}/redirect` } if (ENV === 'staging') { - return `https://${ENV}.${client.name}.tv/redirect` + return `https://c-${ENV}.${client.name}.tv/redirect` } return `https://${client.name}.tv/redirect` } diff --git a/src/features/MatchPage/hooks/useMatchProfile.tsx b/src/features/MatchPage/hooks/useMatchProfile.tsx index 6da293fc..eb89b214 100644 --- a/src/features/MatchPage/hooks/useMatchProfile.tsx +++ b/src/features/MatchPage/hooks/useMatchProfile.tsx @@ -41,6 +41,18 @@ export const useMatchProfile = () => { getMatchInfo(sportType, matchId).then(setMatchProfile) }, [sportType, matchId]) + useEffect(() => { + let getIntervalMatch + if (matchProfile?.live && !matchProfile.youtube_link) { + getIntervalMatch = setInterval( + () => getMatchInfo(sportType, matchId).then(setMatchProfile), 1000 * 10, + ) + } else { + return clearInterval(getIntervalMatch) + } + return undefined + }, [matchProfile, sportType, matchId]) + const { events, matchPlaylists } = useMatchData(matchProfile?.live) const profile = useMemo( diff --git a/src/features/StreamPlayer/components/YoutubePlayer/index.tsx b/src/features/StreamPlayer/components/YoutubePlayer/index.tsx index 99738b30..daf63fd2 100644 --- a/src/features/StreamPlayer/components/YoutubePlayer/index.tsx +++ b/src/features/StreamPlayer/components/YoutubePlayer/index.tsx @@ -12,6 +12,10 @@ export const YoutubePlayer = (props: Props) => { onTouchEnd, onTouchStart, playing, + sizeOptions: { + height, + width, + }, wrapperRef, } = useVideoPlayer(props) @@ -30,12 +34,12 @@ export const YoutubePlayer = (props: Props) => { diff --git a/src/features/StreamPlayer/hooks/index.tsx b/src/features/StreamPlayer/hooks/index.tsx index 42fae2cb..b2a90b8b 100644 --- a/src/features/StreamPlayer/hooks/index.tsx +++ b/src/features/StreamPlayer/hooks/index.tsx @@ -3,6 +3,7 @@ import { useCallback, useEffect, useMemo, + useState, } from 'react' import once from 'lodash/once' @@ -72,6 +73,10 @@ export const useVideoPlayer = ({ onFullscreenClick, wrapperRef, } = useFullscreen() + const [sizeOptions, setSizeOptions] = useState({ + height: wrapperRef.current?.clientHeight, + width: wrapperRef.current?.clientWidth, + }) const togglePlaying = () => { if (ready) { @@ -122,6 +127,15 @@ export const useVideoPlayer = ({ const { isOnline } = useNoNetworkPopupStore() + useEffect(() => { + if (wrapperRef.current) { + setSizeOptions({ + height: wrapperRef.current?.clientHeight, + width: wrapperRef.current?.clientWidth, + }) + } + }, [wrapperRef]) + useEffect(() => { if (!isOnline) { setPlayerState({ playing: false }) @@ -163,6 +177,7 @@ export const useVideoPlayer = ({ rewindBackward: rewind(-REWIND_SECONDS), rewindForward: rewind(REWIND_SECONDS), seek, + sizeOptions, startPlaying, togglePlaying, videoRef,