|
|
|
|
@ -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]) |
|
|
|
|
|
|
|
|
|
|