fix(ott-1804): fixed live button showing on non-live matches (#543)

keep-around/af30b88d367751c9e05a735e4a0467a96238ef47
Andrey Razdorskiy 4 years ago committed by Mirlan
parent 90fc409557
commit 84aa4cc7ed
  1. 10
      src/features/MatchPage/components/LiveMatch/index.tsx
  2. 10
      src/features/Matches/helpers/getMatchClickAction/__tests__/index.tsx
  3. 10
      src/features/StreamPlayer/hooks/index.tsx
  4. 39
      src/features/StreamPlayer/index.tsx

@ -6,9 +6,10 @@ import type { MatchInfo } from 'requests/getMatchInfo'
import { StreamPlayer } from 'features/StreamPlayer' import { StreamPlayer } from 'features/StreamPlayer'
import { MatchSidePlaylists } from 'features/MatchSidePlaylists' import { MatchSidePlaylists } from 'features/MatchSidePlaylists'
import { useLiveMatch } from './hooks'
import { Container } from '../../styled' import { Container } from '../../styled'
import { useLiveMatch } from './hooks'
type Props = { type Props = {
events: Events, events: Events,
profile: MatchInfo, profile: MatchInfo,
@ -29,19 +30,20 @@ export const LiveMatch = ({ events, profile }: Props) => {
<Fragment> <Fragment>
<Container> <Container>
<StreamPlayer <StreamPlayer
url={streamUrl}
onPlayingChange={onPlayingChange} onPlayingChange={onPlayingChange}
onProgressChange={onPlayerProgressChange} onProgressChange={onPlayerProgressChange}
profile={profile}
resumeFrom={resume} resumeFrom={resume}
url={streamUrl}
/> />
</Container> </Container>
<MatchSidePlaylists <MatchSidePlaylists
events={events} events={events}
playlists={matchPlaylists}
selectedPlaylist={selectedPlaylist}
onSelect={onPlaylistSelect} onSelect={onPlaylistSelect}
playlists={matchPlaylists}
profile={profile} profile={profile}
selectedPlaylist={selectedPlaylist}
/> />
</Fragment> </Fragment>
) )

@ -20,6 +20,7 @@ it('equals to no country access type', () => {
access: false, access: false,
sub: false, sub: false,
}) })
expect(getMatchAccess(match)).toBe(MatchAccess.CanBuyMatch) expect(getMatchAccess(match)).toBe(MatchAccess.CanBuyMatch)
}) })
@ -30,6 +31,7 @@ it('equals to redirect type', () => {
has_video: true, has_video: true,
sub: true, sub: true,
}) })
expect(getMatchAccess(match)).toBe(MatchAccess.RedirectToProfile) expect(getMatchAccess(match)).toBe(MatchAccess.RedirectToProfile)
}) })
@ -38,6 +40,7 @@ it('equals to can buy type', () => {
access: true, access: true,
sub: false, sub: false,
}) })
expect(getMatchAccess(match)).toBe(MatchAccess.CanBuyMatch) expect(getMatchAccess(match)).toBe(MatchAccess.CanBuyMatch)
}) })
@ -47,6 +50,7 @@ it('equals to view match popup type', () => {
live: true, live: true,
sub: true, sub: true,
}) })
expect(getMatchAccess(match)).toBe(MatchAccess.ViewMatchPopup) expect(getMatchAccess(match)).toBe(MatchAccess.ViewMatchPopup)
match = createMatch({ match = createMatch({
@ -56,7 +60,8 @@ it('equals to view match popup type', () => {
live: false, live: false,
sub: true, sub: true,
}) })
expect(getMatchAccess(match)).toBe(MatchAccess.ViewMatchPopup)
expect(getMatchAccess(match)).toBe(MatchAccess.RedirectToProfile)
match = createMatch({ match = createMatch({
access: true, access: true,
@ -66,5 +71,6 @@ it('equals to view match popup type', () => {
storage: true, storage: true,
sub: true, sub: true,
}) })
expect(getMatchAccess(match)).toBe(MatchAccess.ViewMatchPopup)
expect(getMatchAccess(match)).toBe(MatchAccess.RedirectToProfile)
}) })

@ -3,14 +3,16 @@ import { useCallback, useMemo } from 'react'
import once from 'lodash/once' import once from 'lodash/once'
import { useVolume } from 'features/VideoPlayer/hooks/useVolume'
import { REWIND_SECONDS } from 'features/MultiSourcePlayer/config'
import { useObjectState } from 'hooks' import { useObjectState } from 'hooks'
import { useVolume } from 'features/VideoPlayer/hooks/useVolume' import type { MatchInfo } from 'requests/getMatchInfo'
import { REWIND_SECONDS } from 'features/MultiSourcePlayer/config'
import { useHlsPlayer } from './useHlsPlayer' import { useHlsPlayer } from './useHlsPlayer'
import { useVideoQuality } from './useVideoQuality'
import { useFullscreen } from './useFullscreen' import { useFullscreen } from './useFullscreen'
import { useVideoQuality } from './useVideoQuality'
import { useControlsVisibility } from './useControlsVisibility' import { useControlsVisibility } from './useControlsVisibility'
const toMilliSeconds = (seconds: number) => seconds * 1000 const toMilliSeconds = (seconds: number) => seconds * 1000
@ -27,6 +29,7 @@ const initialState = {
export type Props = { export type Props = {
onPlayingChange: (playing: boolean) => void, onPlayingChange: (playing: boolean) => void,
onProgressChange: (seconds: number) => void, onProgressChange: (seconds: number) => void,
profile: MatchInfo,
resumeFrom?: number, resumeFrom?: number,
url: string, url: string,
} }
@ -38,6 +41,7 @@ export const useVideoPlayer = ({
url, url,
}: Props) => { }: Props) => {
const { hls, videoRef } = useHlsPlayer(url, resumeFrom) const { hls, videoRef } = useHlsPlayer(url, resumeFrom)
const [{ const [{
duration, duration,
loadedProgress, loadedProgress,

@ -1,14 +1,13 @@
import { secondsToHms } from 'helpers' import { T9n } from 'features/T9n'
import { Loader } from 'features/Loader' import { Loader } from 'features/Loader'
import { Settings } from 'features/MultiSourcePlayer/components/Settings'
import { REWIND_SECONDS } from 'features/MultiSourcePlayer/config' import { REWIND_SECONDS } from 'features/MultiSourcePlayer/config'
import { T9n } from 'features/T9n' import { Settings } from 'features/MultiSourcePlayer/components/Settings'
import { secondsToHms } from 'helpers'
import type { Props } from './hooks'
import { useVideoPlayer } from './hooks'
import { ProgressBar } from './components/ProgressBar'
import { VolumeBar } from './components/VolumeBar' import { VolumeBar } from './components/VolumeBar'
import { ProgressBar } from './components/ProgressBar'
import { import {
PlayerWrapper, PlayerWrapper,
VideoPlayer, VideoPlayer,
@ -25,9 +24,12 @@ import {
ControlsGradient, ControlsGradient,
LiveBtn, LiveBtn,
} from './styled' } from './styled'
import type { Props } from './hooks'
import { useVideoPlayer } from './hooks'
export const StreamPlayer = (props: Props) => { export const StreamPlayer = (props: Props) => {
const { url } = props const { profile, url } = props
const { const {
backToLive, backToLive,
controlsVisible, controlsVisible,
@ -102,18 +104,26 @@ export const StreamPlayer = (props: Props) => {
onError={onError} onError={onError}
crossOrigin='use-credentials' crossOrigin='use-credentials'
/> />
{ready && (
{
ready && (
<CenterControls playing={playing}> <CenterControls playing={playing}>
<Backward size='lg' onClick={rewindBackward}>{REWIND_SECONDS}</Backward> <Backward size='lg' onClick={rewindBackward}>
{REWIND_SECONDS}
</Backward>
<PlayStop <PlayStop
size='lg' size='lg'
marginRight={0} marginRight={0}
playing={playing} playing={playing}
onClick={togglePlaying} onClick={togglePlaying}
/> />
<Forward size='lg' onClick={rewindForward}>{REWIND_SECONDS}</Forward> <Forward size='lg' onClick={rewindForward}>
{REWIND_SECONDS}
</Forward>
</CenterControls> </CenterControls>
)} )
}
<Controls visible={controlsVisible}> <Controls visible={controlsVisible}>
<ControlsRow> <ControlsRow>
<ProgressBar <ProgressBar
@ -139,9 +149,14 @@ export const StreamPlayer = (props: Props) => {
<Forward onClick={rewindForward}>{REWIND_SECONDS}</Forward> <Forward onClick={rewindForward}>{REWIND_SECONDS}</Forward>
</ControlsGroup> </ControlsGroup>
<ControlsGroup> <ControlsGroup>
{
profile?.live && (
<LiveBtn onClick={backToLive}> <LiveBtn onClick={backToLive}>
<T9n t='live' /> <T9n t='live' />
</LiveBtn> </LiveBtn>
)
}
<Fullscreen <Fullscreen
onClick={onFullscreenClick} onClick={onFullscreenClick}
isFullscreen={isFullscreen} isFullscreen={isFullscreen}

Loading…
Cancel
Save