|
|
|
|
@ -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<typeof setInterval> = 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(() => { |
|
|
|
|
|