fix(#175): change route for flags and change setInterval

pull/43/head
Andrei Dekterev 3 years ago
parent 3aca022f7b
commit 5d94670bbc
  1. 14
      src/components/AccessTimer/index.tsx
  2. 1
      src/components/ItemInfo/ItemInfo.tsx
  3. 2
      src/features/FavoritesMobilePopup/components/GroupBlock/index.tsx
  4. 2
      src/features/ItemsList/index.tsx
  5. 31
      src/features/MatchPage/store/hooks/index.tsx
  6. 2
      src/features/MultiSourcePlayer/index.tsx
  7. 2
      src/features/PreferencesPopup/components/TournamentInfo/index.tsx
  8. 2
      src/features/ProfileCard/index.tsx
  9. 2
      src/features/StreamPlayer/index.tsx
  10. 2
      src/features/TournamentList/components/CollapseTournament/index.tsx
  11. 2
      src/features/TournamentList/components/TournamentMobile/index.tsx
  12. 2
      src/features/TournamentSubtitle/index.tsx
  13. 2
      src/features/UserFavorites/TooltipBlock/index.tsx
  14. 2
      src/pages/HighlightsPage/components/MatchesHighlights/index.tsx

@ -1,4 +1,8 @@
import { useEffect, useState } from 'react' import {
useEffect,
useState,
RefObject,
} from 'react'
import { T9n } from 'features/T9n' import { T9n } from 'features/T9n'
import { Icon } from 'features/Icon' import { Icon } from 'features/Icon'
@ -23,8 +27,8 @@ type AccessTimerType = {
access: boolean, access: boolean,
isFullscreen: boolean, isFullscreen: boolean,
onFullscreenClick: () => void, onFullscreenClick: () => void,
onPause: () => void,
playing: boolean, playing: boolean,
videoRef?: RefObject<HTMLVideoElement> | null,
} }
const ACCESS_TIME = 60 const ACCESS_TIME = 60
@ -33,8 +37,8 @@ export const AccessTimer = ({
access, access,
isFullscreen, isFullscreen,
onFullscreenClick, onFullscreenClick,
onPause,
playing, playing,
videoRef,
}: AccessTimerType) => { }: AccessTimerType) => {
const { const {
logout, logout,
@ -46,13 +50,13 @@ export const AccessTimer = ({
const [timeIsFinished, setTimeIsFinished] = useState(true) const [timeIsFinished, setTimeIsFinished] = useState(true)
const [time, setTime] = useState(ACCESS_TIME) const [time, setTime] = useState(ACCESS_TIME)
const isTimeExpired = time <= 0 && !access const isTimeExpired = time <= 0 || !access
useEffect(() => { useEffect(() => {
if (isTimeExpired) { if (isTimeExpired) {
document.pictureInPictureEnabled && document.exitPictureInPicture() document.pictureInPictureEnabled && document.exitPictureInPicture()
setTimeIsFinished(true) setTimeIsFinished(true)
onPause() videoRef?.current?.pause()
setTime(0) setTime(0)
if (isFullscreen) onFullscreenClick() if (isFullscreen) onFullscreenClick()
} }

@ -13,7 +13,6 @@ type ItemInfoType = {
onClick: (val: any) => void, onClick: (val: any) => void,
type: ProfileTypes, type: ProfileTypes,
} }
export const ItemInfo = ({ export const ItemInfo = ({
active, active,
id, id,

@ -69,7 +69,7 @@ export const GroupBlock = ({ groupBlock }: Props) => {
<Name>{name}</Name> <Name>{name}</Name>
<CountryAndTeamInfo> <CountryAndTeamInfo>
<SportIcon sport={item.sport} size={10} /> <SportIcon sport={item.sport} size={10} />
<Flag src={`https://instatscout.com/images/flags/48/${item.info.country?.id}.png`} /> <Flag src={`https://cf-aws.insports.tv/media/flags/${item.info.country?.id}.png`} />
<EmptySpan>{countryOrTeam}</EmptySpan> <EmptySpan>{countryOrTeam}</EmptySpan>
</CountryAndTeamInfo> </CountryAndTeamInfo>
</EmptyDiv> </EmptyDiv>

@ -55,7 +55,7 @@ export const ItemsList = ({
<SportIcon size={isMobileDevice ? 10 : '0.65rem'} sport={item.sport} /> <SportIcon size={isMobileDevice ? 10 : '0.65rem'} sport={item.sport} />
{item.additionalInfo && ( {item.additionalInfo && (
<Fragment> <Fragment>
<Flag src={`https://instatscout.com/images/flags/48/${item.additionalInfo.id}.png`} /> <Flag src={`https://cf-aws.insports.tv/media/flags/${item.additionalInfo.id}.png`} />
<TeamOrCountry nameObj={item.additionalInfo} /> <TeamOrCountry nameObj={item.additionalInfo} />
</Fragment> </Fragment>
)} )}

@ -58,6 +58,19 @@ export const useMatchPage = () => {
toggleActivePlayers, toggleActivePlayers,
} = useFiltersPopup() } = useFiltersPopup()
const getMatchViewDuration = () => (getViewMatchDuration({
matchId,
sportType,
userId: Number(userInfo?.email),
}).then(({
duration,
error,
}) => {
if (error || (duration && Number(duration) > ACCESS_TIME)) {
setAccess(false)
}
}))
useEffect(() => { useEffect(() => {
getMatchInfo(sportType, matchId).then(setMatchProfile) getMatchInfo(sportType, matchId).then(setMatchProfile)
}, [sportType, matchId]) }, [sportType, matchId])
@ -78,26 +91,14 @@ export const useMatchPage = () => {
useEffect(() => { useEffect(() => {
if (user) return if (user) return
const getIntervalMatch: ReturnType<typeof setInterval> = setInterval( const counter = setInterval(
() => getViewMatchDuration({ () => getMatchViewDuration(), 1000 * 30,
matchId,
sportType,
userId: Number(userInfo?.email),
}).then(({
duration,
error,
}) => {
if (error || (duration && Number(duration) > ACCESS_TIME)) {
setAccess(false)
}
}), 1000 * 30,
) )
// eslint-disable-next-line // eslint-disable-next-line
return () => clearInterval(getIntervalMatch) return () => clearInterval(counter)
// eslint-disable-next-line react-hooks/exhaustive-deps // eslint-disable-next-line react-hooks/exhaustive-deps
}, [ }, [
user, user,
matchProfile,
sportType, sportType,
matchId, matchId,
]) ])

@ -225,7 +225,7 @@ export const MultiSourcePlayer = (props: Props) => {
isFullscreen={isFullscreen} isFullscreen={isFullscreen}
onFullscreenClick={onFullscreenClick} onFullscreenClick={onFullscreenClick}
playing={ready && playing && !!playedProgress} playing={ready && playing && !!playedProgress}
onPause={onPause} videoRef={currentVideo}
/> />
)} )}
</PlayerWrapper> </PlayerWrapper>

@ -51,7 +51,7 @@ export const TournamentInfo = ({
<StyledName nameObj={tournament} className='title' prefix={prefix} /> <StyledName nameObj={tournament} className='title' prefix={prefix} />
<ItemInfo> <ItemInfo>
{isIcon && <SportIcon size={isMobileDevice ? 10 : '0.65rem'} sport={tournament.sport} />} {isIcon && <SportIcon size={isMobileDevice ? 10 : '0.65rem'} sport={tournament.sport} />}
<Flag src={`https://instatscout.com/images/flags/48/${tournament.country.id}.png`} /> <Flag src={`https://cf-aws.insports.tv/media/flags/${tournament.country.id}.png`} />
<TeamOrCountry nameObj={tournament.country} /> <TeamOrCountry nameObj={tournament.country} />
</ItemInfo> </ItemInfo>
</Wrapper> </Wrapper>

@ -75,7 +75,7 @@ export const ProfileCard = ({ profile }: ProfileType) => {
<Details> <Details>
<ProfileName>{name}</ProfileName> <ProfileName>{name}</ProfileName>
<InfoItems> <InfoItems>
<InfoFlag src={`https://instatscout.com/images/flags/48/${profile.additionalInfo.id}.png`} /> <InfoFlag src={`https://cf-aws.insports.tv/media/flags/${profile.additionalInfo.id}.png`} />
{tournamentId {tournamentId
? ( ? (
<StyledLink <StyledLink

@ -203,7 +203,7 @@ export const StreamPlayer = (props: Props) => {
isFullscreen={isFullscreen} isFullscreen={isFullscreen}
onFullscreenClick={onFullscreenClick} onFullscreenClick={onFullscreenClick}
playing={ready && playing && !!playedProgress} playing={ready && playing && !!playedProgress}
onPause={onPause} videoRef={videoRef}
/> />
)} )}
</PlayerWrapper> </PlayerWrapper>

@ -93,7 +93,7 @@ export const CollapseTournament = ({
</SportWrapper> </SportWrapper>
<CountryWrapper> <CountryWrapper>
<CountryFlag <CountryFlag
src={`https://instatscout.com/images/flags/48/${countryId}.png`} src={`https://cf-aws.insports.tv/media/flags/${countryId}.png`}
/> />
{countryInfo && ( {countryInfo && (
<Tooltip> <Tooltip>

@ -54,7 +54,7 @@ export const TournamentMobile = ({
sport={sportType} sport={sportType}
/> />
<CountryFlag <CountryFlag
src={`https://instatscout.com/images/flags/48/${countryId}.png`} src={`https://cf-aws.insports.tv/media/flags/${countryId}.png`}
/> />
</Fragment> </Fragment>
)} )}

@ -72,7 +72,7 @@ export const TournamentSubtitle = ({
)} )}
</SportWrapper> </SportWrapper>
<CountryWrapper> <CountryWrapper>
<CountryFlag src={`https://instatscout.com/images/flags/48/${countryId}.png`} /> <CountryFlag src={`https://cf-aws.insports.tv/media/flags/${countryId}.png`} />
{countryInfo && ( {countryInfo && (
<Tooltip> <Tooltip>
<Name nameObj={countryInfo} /> <Name nameObj={countryInfo} />

@ -32,7 +32,7 @@ export const TooltipBlock = ({
</TooltipBlockItem> </TooltipBlockItem>
<TooltipBlockItemThin> <TooltipBlockItemThin>
{info?.team && <Name nameObj={info.team} />}{' '} {info?.team && <Name nameObj={info.team} />}{' '}
{info?.country && <Flag src={`https://instatscout.com/images/flags/48/${info.country.id}.png`} />} {info?.country && <Flag src={`https://cf-aws.insports.tv/media/flags/${info.country.id}.png`} />}
</TooltipBlockItemThin> </TooltipBlockItemThin>
</TooltipBlockWrapper> </TooltipBlockWrapper>
) )

@ -75,7 +75,7 @@ export const MatchesHighlights = () => {
<ScTournament> <ScTournament>
<SportIcon sport={sport} /> <SportIcon sport={sport} />
<ScCountryFlag <ScCountryFlag
src={`https://instatscout.com/images/flags/48/${country_id}.png`} src={`https://cf-aws.insports.tv/media/flags/${country_id}.png`}
/> />
<ScTournamentName>{tournament.name_eng}</ScTournamentName> <ScTournamentName>{tournament.name_eng}</ScTournamentName>
</ScTournament> </ScTournament>

Loading…
Cancel
Save