Compare commits

...

2 Commits

Author SHA1 Message Date
Andrei Dekterev e1a7f05f26 fix(#video-duration): calculate video duration for unfinished video after live 3 years ago
Andrei Dekterev 8e08fbadd9 fix(#black-screen): remove tokens 3 years ago
  1. 13
      src/features/App/index.tsx
  2. 8
      src/features/MatchPage/components/LiveMatch/helpers.tsx
  3. 1
      src/features/MatchPage/store/hooks/useMatchData.tsx
  4. 4
      src/features/StreamPlayer/hooks/index.tsx
  5. 11
      src/helpers/callApi/logoutIfUnauthorized.tsx

@ -1,8 +1,4 @@
import {
Suspense,
useEffect,
useState,
} from 'react'
import { Suspense } from 'react'
import { Router } from 'react-router-dom'
import { QueryClient, QueryClientProvider } from 'react-query'
import { ReactQueryDevtools } from 'react-query/devtools'
@ -31,16 +27,11 @@ import { useAuthStore } from '../AuthStore'
setClientTitleAndDescription(client.title, client.description)
const Main = () => {
const [isToken, setIsToken] = useState(false)
const { userInfo } = useAuthStore()
const queryClient = new QueryClient()
useEffect(() => {
if (userInfo) readToken() && setIsToken(true)
}, [userInfo])
// имеется действующий токен
return isToken ? (
return userInfo && readToken() ? (
<ErrorBoundary>
<QueryClientProvider client={queryClient}>
<ReactQueryDevtools initialIsOpen={isLocalhost} />

@ -40,11 +40,13 @@ const getFullMatchChapters = ({
? ((playlist.duration ?? 0) - Number(bound.s)) * 1000
: (playlist.duration ?? 0) * 1000
const delayedDuration = Math.max(durationMs, Number(bound?.e ?? 0)) * 1000
return [
{
duration: durationMs,
endMs: durationMs,
endOffsetMs: bound ? Number(bound.e) * 1000 : durationMs,
duration: delayedDuration,
endMs: delayedDuration,
endOffsetMs: delayedDuration,
index: 0,
isFullMatchChapter: true,
startMs: 0,

@ -45,6 +45,7 @@ export const useMatchData = (profile: MatchInfo) => {
const fullMatchDuration = matchDuration
useEffect(() => {
if (!profile || (profile.live && Number(profile.c_match_calc_status) <= 1)) return
fetchMatchPlaylists({
fullMatchDuration,
id: matchId,

@ -363,8 +363,8 @@ export const useVideoPlayer = ({
}, [isLive, chaptersProps[0].startOffsetMs])
useEffect(() => {
if (((isLive || chapters[0].duration === chaptersProps[0].duration)
&& chapters[0]?.endOffsetMs === chaptersProps[0]?.endOffsetMs
if (((isLive || Boolean(Math.round((chapters[0].duration / chaptersProps[0].duration))))
&& Boolean(Math.round(chapters[0]?.endOffsetMs / chaptersProps[0]?.endOffsetMs))
&& chapters[0]?.url.match(regURL)?.[0] === chaptersProps[0]?.url.match(regURL)?.[0])
|| (isEmpty(chapters) || isEmpty(chaptersProps))) return

@ -1,13 +1,22 @@
import { removeToken } from '../token'
import { removeCookie } from '../cookie'
export const logoutIfUnauthorized = async (response: Response) => {
/* отключили из-за доступа без авторизации */
const body = await response.json()
if (response.status === 401 || response.status === 403) {
window.dispatchEvent(new Event('FORBIDDEN_REQUEST'))
if (body.message.includes('Signature has expired')) {
removeToken()
removeCookie('access_token')
}
}
const error = new Error(response.statusText)
// eslint-disable-next-line no-console
console.error(error)
const body = await response.json()
return Promise.reject(body)
}

Loading…
Cancel
Save