feat(ott-345): deleted timer (#108)

keep-around/af30b88d367751c9e05a735e4a0467a96238ef47
Armen 5 years ago committed by GitHub
parent 9da11400d9
commit 2f5365dceb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 28
      src/features/MatchCard/CardLive/index.tsx

@ -1,14 +1,9 @@
import React, {
useState,
useEffect,
useCallback,
} from 'react'
import React from 'react'
import styled from 'styled-components/macro'
import differenceInMilliseconds from 'date-fns/differenceInMilliseconds'
import type { Match } from 'features/Matches'
import { getSportColor, msToMinutesAndSeconds } from 'helpers'
import { getSportColor } from 'helpers'
import { SportName } from 'features/Common'
import { T9n } from 'features/T9n'
@ -27,8 +22,6 @@ import {
} from '../styled'
import { CardLiveHover } from '../CardLiveHover'
const UPDATE_INTERVAL = 1000
const MatchStatus = styled(CommonMatchStatus)`
color: #fff;
background-color: #cc0000;
@ -60,21 +53,6 @@ export const CardLive = ({
showScore,
} = useCard()
const getMs = useCallback(() => differenceInMilliseconds(
new Date(),
new Date(date),
), [date])
const [matchDuration, setMatchDuration] = useState(msToMinutesAndSeconds(getMs()))
useEffect(() => {
const timer = setInterval(() => {
setMatchDuration(msToMinutesAndSeconds(getMs()))
}, UPDATE_INTERVAL)
return () => clearInterval(timer)
}, [getMs])
if (isOpen) return <CardLiveHover onClose={close} />
return (
@ -82,7 +60,7 @@ export const CardLive = ({
onClick={open}
onKeyPress={onKeyPress}
>
<MatchStatus><T9n t='live' /> {matchDuration}</MatchStatus>
<MatchStatus><T9n t='live' /></MatchStatus>
<PreviewWrapper>
<Preview
alt={tournamentName}

Loading…
Cancel
Save