fix(599): play abc=0 if there is any (#235)

keep-around/af30b88d367751c9e05a735e4a0467a96238ef47
Mirlan 5 years ago committed by GitHub
parent 34424d86b7
commit 0c46c74b16
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      src/features/MatchPage/hooks/useVideoData.tsx
  2. 3
      src/requests/getVideos.tsx

@ -4,6 +4,7 @@ import {
useState,
} from 'react'
import isEmpty from 'lodash/isEmpty'
import filter from 'lodash/filter'
import type { LiveVideos, Videos } from 'requests'
@ -13,6 +14,11 @@ import { useSportNameParam, usePageId } from 'hooks'
import { useLastPlayPosition } from './useLastPlayPosition'
const filterByIds = (videos: Videos) => {
const zeroIdVideos = filter(videos, { abc: 0 })
return isEmpty(zeroIdVideos) ? videos : zeroIdVideos
}
export const useVideoData = () => {
const [videos, setVideos] = useState<Videos>([])
const [liveVideos, setLiveVideos] = useState<LiveVideos>([])
@ -21,7 +27,7 @@ export const useVideoData = () => {
const fetchMatchVideos = useCallback(async () => {
const videosResponse = await getVideos(sportType, matchId)
const filteredVideosResponseByAbc = filter(videosResponse, (vid) => vid.abc !== 1)
const filteredVideosResponseByAbc = filterByIds(videosResponse)
setVideos(filteredVideosResponseByAbc)
}, [sportType, matchId])

@ -2,10 +2,9 @@ import { API_ROOT, SportTypes } from 'config'
import { callApi } from 'helpers'
type Video = {
/** id дорожки */
abc: number,
duration: number,
match_id: number,
name: string,
period: number,
quality: string,
start_ms: number,

Loading…
Cancel
Save