fix(ott-2850): remove changes from video tab

keep-around/2fd168b18eeebc91eac94ae86d817c12edfe1576
boyvanov 3 years ago
parent b3f3586b31
commit d7f52f07f6
  1. 8
      src/features/MatchSidePlaylists/components/TabVideo/index.tsx
  2. 8
      src/features/MatchSidePlaylists/components/TabVideo/styled.tsx
  3. 29
      src/features/MatchSidePlaylists/index.tsx
  4. 27
      src/features/MatchSidePlaylists/useScroll.tsx

@ -19,7 +19,6 @@ import { usePageParams } from 'hooks/usePageParams'
import { VideoDate } from './components/VideoDate' import { VideoDate } from './components/VideoDate'
import { MatchesWrapper } from './styled' import { MatchesWrapper } from './styled'
import { useScroll } from '../../useScroll'
type Props = { type Props = {
profile: MatchInfo, profile: MatchInfo,
@ -40,8 +39,6 @@ export const TabVideo = ({
const [selectedDate, setSelectedDate] = useState(profileDate) const [selectedDate, setSelectedDate] = useState(profileDate)
const { hasScroll, ref } = useScroll([selectedDate])
const matches = useMemo(() => ( const matches = useMemo(() => (
tournamentData.matches.filter((match) => ( tournamentData.matches.filter((match) => (
formatDate(match.date) === selectedDate && match.id !== profileId formatDate(match.date) === selectedDate && match.id !== profileId
@ -73,10 +70,7 @@ export const TabVideo = ({
profileDate={profileDate} profileDate={profileDate}
onDateClick={setSelectedDate} onDateClick={setSelectedDate}
/> />
<MatchesWrapper <MatchesWrapper>
hasScroll={hasScroll}
ref={ref}
>
{ {
map(sortBy(matches, ({ live }) => !live), (match) => ( map(sortBy(matches, ({ live }) => !live), (match) => (
<MatchCard <MatchCard

@ -2,14 +2,10 @@ import styled, { css } from 'styled-components/macro'
import { customScrollbar } from 'features/Common' import { customScrollbar } from 'features/Common'
import { isMobileDevice } from '../../../../config/userAgent' import { isMobileDevice } from '../../../../config/userAgent'
type TMatchesWrapper = { export const MatchesWrapper = styled.div`
hasScroll: boolean,
}
export const MatchesWrapper = styled.div<TMatchesWrapper>`
overflow-y: auto; overflow-y: auto;
max-height: calc(100vh - 170px); max-height: calc(100vh - 170px);
${({ hasScroll }) => (hasScroll ? css`padding-right: 5px;` : '')} padding-right: 5px;
> * { > * {
margin-bottom: 15px; margin-bottom: 15px;

@ -1,4 +1,8 @@
import { useRef } from 'react' import {
useEffect,
useRef,
useState,
} from 'react'
import type { PlaylistOption } from 'features/MatchPage/types' import type { PlaylistOption } from 'features/MatchPage/types'
import { Tab, TabsGroup } from 'features/Common' import { Tab, TabsGroup } from 'features/Common'
@ -14,7 +18,6 @@ import { TabEvents } from './components/TabEvents'
import { TabWatch } from './components/TabWatch' import { TabWatch } from './components/TabWatch'
import { TabVideo } from './components/TabVideo' import { TabVideo } from './components/TabVideo'
import { useMatchSidePlaylists } from './hooks' import { useMatchSidePlaylists } from './hooks'
import { useScroll } from './useScroll'
import { import {
Wrapper, Wrapper,
TabsWrapper, TabsWrapper,
@ -54,13 +57,25 @@ export const MatchSidePlaylists = ({
const TabPane = tabPanes[selectedTab] const TabPane = tabPanes[selectedTab]
const { hasScroll, ref } = useScroll([ const containerRef = useRef<HTMLDivElement | null>(null)
const tabPaneContainerRef = useRef<HTMLDivElement | null>(null)
const [hasTabPaneScroll, setTabPaneScroll] = useState(false)
useEffect(() => {
const {
clientHeight = 0,
scrollHeight = 0,
} = tabPaneContainerRef.current || {}
const hasScroll = scrollHeight > clientHeight
setTabPaneScroll(hasScroll)
}, [
playlists, playlists,
selectedTab, selectedTab,
tabPaneContainerRef,
]) ])
const containerRef = useRef<HTMLDivElement | null>(null)
useEventListener({ useEventListener({
callback: () => { callback: () => {
const screenLandscape = isIOS ? window.orientation : window.screen.orientation.type const screenLandscape = isIOS ? window.orientation : window.screen.orientation.type
@ -108,8 +123,8 @@ export const MatchSidePlaylists = ({
</TabsWrapper> </TabsWrapper>
<Container <Container
hasScroll={hasScroll} hasScroll={hasTabPaneScroll}
ref={ref} ref={tabPaneContainerRef}
forVideoTab={selectedTab === Tabs.VIDEO} forVideoTab={selectedTab === Tabs.VIDEO}
> >
<TabPane <TabPane

@ -1,27 +0,0 @@
import {
useEffect,
useRef,
useState,
} from 'react'
export const useScroll = (deps: any) => {
const ref = useRef<HTMLDivElement | null>(null)
const [hasRefScroll, setRefScroll] = useState(false)
useEffect(() => {
const {
clientHeight = 0,
scrollHeight = 0,
} = ref.current || {}
const hasScroll = scrollHeight > clientHeight
setRefScroll(hasScroll)
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [ref, ...deps])
return {
hasScroll: hasRefScroll,
ref,
}
}
Loading…
Cancel
Save