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