fix: add setter and give props
This commit is contained in:
parent
156f177497
commit
2049b40185
|
@ -1,23 +1,32 @@
|
||||||
|
import { useEffect, useState } from 'react'
|
||||||
import { XStack, YStack } from 'tamagui'
|
import { XStack, YStack } from 'tamagui'
|
||||||
import { Button, IconButton, InformationBox, Text } from '@status-im/components'
|
import { Button, IconButton, InformationBox, Text } from '@status-im/components'
|
||||||
|
|
||||||
import Icon from '../../components/General/Icon'
|
import Icon from '../../components/General/Icon'
|
||||||
import RefreshBlackIcon from '/icons/refresh-black.svg'
|
import RefreshBlackIcon from '/icons/refresh-black.svg'
|
||||||
import RefreshIcon from '/icons/refresh.svg'
|
import RefreshIcon from '/icons/refresh.svg'
|
||||||
import BlockIcon from '/icons/block.svg'
|
import BlockIcon from '/icons/block.svg'
|
||||||
import ConnectionIcon from '/icons/connection.svg'
|
import ConnectionIcon from '/icons/connection.svg'
|
||||||
import { convertSecondsToTimerFormat } from '../../utilities'
|
import { convertSecondsToTimerFormat } from '../../utilities'
|
||||||
import { useEffect, useState } from 'react'
|
|
||||||
type SyncStatusProps = {
|
type SyncStatusProps = {
|
||||||
isPairing: boolean
|
isPairing: boolean
|
||||||
isPairedSuccessfully: boolean
|
isPairedSuccessfully: boolean
|
||||||
|
isAwaitingPairing?: boolean
|
||||||
|
changeSetIsAwaitingPairing: (isAwaitingPairing: boolean) => void
|
||||||
}
|
}
|
||||||
const SyncStatus = ({ isPairing, isPairedSuccessfully }: SyncStatusProps) => {
|
|
||||||
|
const SyncStatus = ({
|
||||||
|
isPairing,
|
||||||
|
isAwaitingPairing,
|
||||||
|
changeSetIsAwaitingPairing,
|
||||||
|
isPairedSuccessfully
|
||||||
|
}: SyncStatusProps) => {
|
||||||
const [elapsedTime, setElapsedTime] = useState(0)
|
const [elapsedTime, setElapsedTime] = useState(0)
|
||||||
const [isAwaitingPairing, setIsAwaitingPairing] = useState(false)
|
|
||||||
|
|
||||||
const resetTimer = () => {
|
const resetTimer = () => {
|
||||||
setElapsedTime(0)
|
setElapsedTime(0)
|
||||||
setIsAwaitingPairing(false)
|
changeSetIsAwaitingPairing(false)
|
||||||
}
|
}
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
let timer: ReturnType<typeof setTimeout>
|
let timer: ReturnType<typeof setTimeout>
|
||||||
|
@ -26,11 +35,11 @@ const SyncStatus = ({ isPairing, isPairedSuccessfully }: SyncStatusProps) => {
|
||||||
timer = setInterval(() => {
|
timer = setInterval(() => {
|
||||||
setElapsedTime(prevTime => prevTime + 65)
|
setElapsedTime(prevTime => prevTime + 65)
|
||||||
if (elapsedTime >= 180) {
|
if (elapsedTime >= 180) {
|
||||||
setIsAwaitingPairing(true)
|
changeSetIsAwaitingPairing(true)
|
||||||
}
|
}
|
||||||
}, 1000)
|
}, 1000)
|
||||||
} else {
|
} else {
|
||||||
setIsAwaitingPairing(false)
|
changeSetIsAwaitingPairing(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
return () => clearInterval(timer)
|
return () => clearInterval(timer)
|
||||||
|
|
Loading…
Reference in New Issue