diff --git a/src/components/AccessTimer/index.tsx b/src/components/AccessTimer/index.tsx index 77bd74fd..faebddbe 100644 --- a/src/components/AccessTimer/index.tsx +++ b/src/components/AccessTimer/index.tsx @@ -1,4 +1,8 @@ -import { useEffect, useState } from 'react' +import { + useEffect, + useState, + RefObject, +} from 'react' import { T9n } from 'features/T9n' import { Icon } from 'features/Icon' @@ -23,8 +27,8 @@ type AccessTimerType = { access: boolean, isFullscreen: boolean, onFullscreenClick: () => void, - onPause: () => void, playing: boolean, + videoRef?: RefObject | null, } const ACCESS_TIME = 60 @@ -33,8 +37,8 @@ export const AccessTimer = ({ access, isFullscreen, onFullscreenClick, - onPause, playing, + videoRef, }: AccessTimerType) => { const { logout, @@ -46,13 +50,13 @@ export const AccessTimer = ({ const [timeIsFinished, setTimeIsFinished] = useState(true) const [time, setTime] = useState(ACCESS_TIME) - const isTimeExpired = time <= 0 && !access + const isTimeExpired = time <= 0 || !access useEffect(() => { if (isTimeExpired) { document.pictureInPictureEnabled && document.exitPictureInPicture() setTimeIsFinished(true) - onPause() + videoRef?.current?.pause() setTime(0) if (isFullscreen) onFullscreenClick() } diff --git a/src/components/ItemInfo/ItemInfo.tsx b/src/components/ItemInfo/ItemInfo.tsx index 0bc42ffc..3dc2af82 100644 --- a/src/components/ItemInfo/ItemInfo.tsx +++ b/src/components/ItemInfo/ItemInfo.tsx @@ -13,7 +13,6 @@ type ItemInfoType = { onClick: (val: any) => void, type: ProfileTypes, } - export const ItemInfo = ({ active, id, diff --git a/src/features/FavoritesMobilePopup/components/GroupBlock/index.tsx b/src/features/FavoritesMobilePopup/components/GroupBlock/index.tsx index 953fa505..94e08c0d 100644 --- a/src/features/FavoritesMobilePopup/components/GroupBlock/index.tsx +++ b/src/features/FavoritesMobilePopup/components/GroupBlock/index.tsx @@ -69,7 +69,7 @@ export const GroupBlock = ({ groupBlock }: Props) => { {name} - + {countryOrTeam} diff --git a/src/features/ItemsList/index.tsx b/src/features/ItemsList/index.tsx index 5788b6d3..1f9534c7 100644 --- a/src/features/ItemsList/index.tsx +++ b/src/features/ItemsList/index.tsx @@ -55,7 +55,7 @@ export const ItemsList = ({ {item.additionalInfo && ( - + )} diff --git a/src/features/MatchPage/store/hooks/index.tsx b/src/features/MatchPage/store/hooks/index.tsx index 01e483bd..55ac7a2b 100644 --- a/src/features/MatchPage/store/hooks/index.tsx +++ b/src/features/MatchPage/store/hooks/index.tsx @@ -58,6 +58,19 @@ export const useMatchPage = () => { toggleActivePlayers, } = useFiltersPopup() + const getMatchViewDuration = (id: number) => (getViewMatchDuration({ + matchId, + sportType, + userId: id, + }).then(({ + duration, + error, + }) => { + if (error || (duration && Number(duration) > ACCESS_TIME)) { + setAccess(false) + } + })) + useEffect(() => { getMatchInfo(sportType, matchId).then(setMatchProfile) }, [sportType, matchId]) @@ -76,30 +89,18 @@ export const useMatchPage = () => { matchId]) useEffect(() => { - if (user) return - - const getIntervalMatch: ReturnType = setInterval( - () => getViewMatchDuration({ - matchId, - sportType, - userId: Number(userInfo?.email), - }).then(({ - duration, - error, - }) => { - if (error || (duration && Number(duration) > ACCESS_TIME)) { - setAccess(false) - } - }), 1000 * 30, + if (user || !userInfo?.email) return + + const counter = setInterval( + () => getMatchViewDuration(Number(userInfo?.email)), 1000 * 30, ) // eslint-disable-next-line - return () => clearInterval(getIntervalMatch) + return () => clearInterval(counter) // eslint-disable-next-line react-hooks/exhaustive-deps }, [ - user, - matchProfile, sportType, matchId, + userInfo, ]) useEffect(() => { diff --git a/src/features/MultiSourcePlayer/index.tsx b/src/features/MultiSourcePlayer/index.tsx index e3883583..f75e1ada 100644 --- a/src/features/MultiSourcePlayer/index.tsx +++ b/src/features/MultiSourcePlayer/index.tsx @@ -225,7 +225,7 @@ export const MultiSourcePlayer = (props: Props) => { isFullscreen={isFullscreen} onFullscreenClick={onFullscreenClick} playing={ready && playing && !!playedProgress} - onPause={onPause} + videoRef={currentVideo} /> )} diff --git a/src/features/PreferencesPopup/components/TournamentInfo/index.tsx b/src/features/PreferencesPopup/components/TournamentInfo/index.tsx index b168cf29..ac4c53fd 100644 --- a/src/features/PreferencesPopup/components/TournamentInfo/index.tsx +++ b/src/features/PreferencesPopup/components/TournamentInfo/index.tsx @@ -51,7 +51,7 @@ export const TournamentInfo = ({ {isIcon && } - + diff --git a/src/features/ProfileCard/index.tsx b/src/features/ProfileCard/index.tsx index 43e66854..464b42d6 100644 --- a/src/features/ProfileCard/index.tsx +++ b/src/features/ProfileCard/index.tsx @@ -75,7 +75,7 @@ export const ProfileCard = ({ profile }: ProfileType) => {
{name} - + {tournamentId ? ( { isFullscreen={isFullscreen} onFullscreenClick={onFullscreenClick} playing={ready && playing && !!playedProgress} - onPause={onPause} + videoRef={videoRef} /> )} diff --git a/src/features/TournamentList/components/CollapseTournament/index.tsx b/src/features/TournamentList/components/CollapseTournament/index.tsx index 0b5abc1a..a796c808 100644 --- a/src/features/TournamentList/components/CollapseTournament/index.tsx +++ b/src/features/TournamentList/components/CollapseTournament/index.tsx @@ -93,7 +93,7 @@ export const CollapseTournament = ({ {countryInfo && ( diff --git a/src/features/TournamentList/components/TournamentMobile/index.tsx b/src/features/TournamentList/components/TournamentMobile/index.tsx index 2eeb55a3..69f6e0c4 100644 --- a/src/features/TournamentList/components/TournamentMobile/index.tsx +++ b/src/features/TournamentList/components/TournamentMobile/index.tsx @@ -54,7 +54,7 @@ export const TournamentMobile = ({ sport={sportType} /> )} diff --git a/src/features/TournamentSubtitle/index.tsx b/src/features/TournamentSubtitle/index.tsx index 53b67a70..897db6a9 100644 --- a/src/features/TournamentSubtitle/index.tsx +++ b/src/features/TournamentSubtitle/index.tsx @@ -72,7 +72,7 @@ export const TournamentSubtitle = ({ )} - + {countryInfo && ( diff --git a/src/features/UserFavorites/TooltipBlock/index.tsx b/src/features/UserFavorites/TooltipBlock/index.tsx index c9986471..bc7c62ec 100644 --- a/src/features/UserFavorites/TooltipBlock/index.tsx +++ b/src/features/UserFavorites/TooltipBlock/index.tsx @@ -32,7 +32,7 @@ export const TooltipBlock = ({ {info?.team && }{' '} - {info?.country && } + {info?.country && } ) diff --git a/src/pages/HighlightsPage/components/MatchesHighlights/index.tsx b/src/pages/HighlightsPage/components/MatchesHighlights/index.tsx index d858b131..4c164e73 100644 --- a/src/pages/HighlightsPage/components/MatchesHighlights/index.tsx +++ b/src/pages/HighlightsPage/components/MatchesHighlights/index.tsx @@ -75,7 +75,7 @@ export const MatchesHighlights = () => { {tournament.name_eng}