From 0c46c74b1667bbf37dc6fe6bd7e0c4c5970082f5 Mon Sep 17 00:00:00 2001 From: Mirlan Date: Wed, 2 Dec 2020 14:57:29 +0600 Subject: [PATCH] fix(599): play abc=0 if there is any (#235) --- src/features/MatchPage/hooks/useVideoData.tsx | 8 +++++++- src/requests/getVideos.tsx | 3 +-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/features/MatchPage/hooks/useVideoData.tsx b/src/features/MatchPage/hooks/useVideoData.tsx index 60d64b09..7e2a82c9 100644 --- a/src/features/MatchPage/hooks/useVideoData.tsx +++ b/src/features/MatchPage/hooks/useVideoData.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([]) const [liveVideos, setLiveVideos] = useState([]) @@ -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]) diff --git a/src/requests/getVideos.tsx b/src/requests/getVideos.tsx index 9c7ba720..485110fc 100644 --- a/src/requests/getVideos.tsx +++ b/src/requests/getVideos.tsx @@ -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,