From 4330dd7d74aa99b46f462cea45576dae527a47ea Mon Sep 17 00:00:00 2001 From: Andrei Dekterev Date: Fri, 8 Apr 2022 18:29:49 +0700 Subject: [PATCH] fix(#1701): fix red line --- src/features/MatchPage/store/hooks/useEvents.tsx | 1 + src/features/MatchPopup/types.tsx | 4 ++-- .../ProgressBar/helpers/calculateChapterStyles/index.tsx | 2 +- src/features/StreamPlayer/hooks/index.tsx | 9 +++++---- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/features/MatchPage/store/hooks/useEvents.tsx b/src/features/MatchPage/store/hooks/useEvents.tsx index 14f7095c..88be9b67 100644 --- a/src/features/MatchPage/store/hooks/useEvents.tsx +++ b/src/features/MatchPage/store/hooks/useEvents.tsx @@ -18,6 +18,7 @@ export const useEvents = () => { sportType, }).then(fetchLexics) .then(setEvents) + .catch(() => setEvents([])) }, [ fetchLexics, matchId, diff --git a/src/features/MatchPopup/types.tsx b/src/features/MatchPopup/types.tsx index 142d51bf..c611b094 100644 --- a/src/features/MatchPopup/types.tsx +++ b/src/features/MatchPopup/types.tsx @@ -38,8 +38,8 @@ export type SettingsBySport = Partial> export const defaultSettings: Settings = { episodeDuration: { - after: 20, - before: 6, + after: 30, + before: 10, }, selectedActions: [], selectedFormat: PlayerPlaylistFormats.ALL_MATCH_TIME, diff --git a/src/features/StreamPlayer/components/ProgressBar/helpers/calculateChapterStyles/index.tsx b/src/features/StreamPlayer/components/ProgressBar/helpers/calculateChapterStyles/index.tsx index 101a6951..8d6dd2f3 100644 --- a/src/features/StreamPlayer/components/ProgressBar/helpers/calculateChapterStyles/index.tsx +++ b/src/features/StreamPlayer/components/ProgressBar/helpers/calculateChapterStyles/index.tsx @@ -49,7 +49,7 @@ export const calculateChapterStyles = ({ const activeChapter = { ...chapter, loaded: calculateChapterProgress(loadedProgress, chapter), - played: calculateChapterProgress(playedProgress, chapter), + played: playedProgress * 100 / videoDuration, width: chapter.isFullMatchChapter ? 100 : chapter.duration * 100 / videoDuration, diff --git a/src/features/StreamPlayer/hooks/index.tsx b/src/features/StreamPlayer/hooks/index.tsx index 2a34f1bb..d89fdd88 100644 --- a/src/features/StreamPlayer/hooks/index.tsx +++ b/src/features/StreamPlayer/hooks/index.tsx @@ -121,7 +121,7 @@ export const useVideoPlayer = ({ const rewindForward = () => { const chapter = getActiveChapter() const newProgress = playedProgress + REWIND_SECONDS * 1000 - if (newProgress <= chapter.duration) { + if (newProgress <= chapter.duration || isLive) { seekTo(chapter.startOffsetMs + newProgress) } else if (isLastChapterPlaying) { playNextChapter() @@ -158,9 +158,6 @@ export const useVideoPlayer = ({ const onWaiting = () => { setPlayerState({ buffering: true }) - if (!playing) { - setPlayerState({ buffering: false }) - } } const onPlaying = () => { @@ -221,6 +218,10 @@ export const useVideoPlayer = ({ useEffect(() => { onPlayingChange(playing) + if (playing) { + setPlayerState({ buffering: false }) + } + // eslint-disable-next-line }, [playing, onPlayingChange]) useEffect(() => {