import React, { Component } from 'react'
import PropTypes from 'prop-types'
import { Redirect } from 'react-router-dom'
import QRCode from 'qrcode.react'
import copy from 'copy-to-clipboard'
import Copy from 'components/Icon/Copy'
import ZapLogo from 'components/Icon/ZapLogo'
import ZapLogoBlack from 'components/Icon/ZapLogoBlack'
import { showNotification } from 'lib/utils/notifications'
import { FormattedMessage, injectIntl } from 'react-intl'
import messages from './messages'
import styles from './Syncing.scss'
class Syncing extends Component {
static propTypes = {
address: PropTypes.string.isRequired,
theme: PropTypes.object.isRequired,
hasSynced: PropTypes.bool,
syncStatus: PropTypes.string.isRequired,
syncPercentage: PropTypes.number,
blockHeight: PropTypes.number,
lndBlockHeight: PropTypes.number,
lndCfilterHeight: PropTypes.number
}
state = {
timer: null,
syncMessageDetail: null,
syncMessageExtraDetail: null
}
componentWillMount() {
const { syncStatus, intl } = this.props
// If we are still waiting for peers after some time, advise te user it could take a wile.
let timer = setTimeout(() => {
if (syncStatus === 'waiting') {
this.setState({
syncMessageDetail: intl.formatMessage({ ...messages.grab_coffee })
})
}
}, 10000)
this.setState({ timer })
}
componentWillUnmount() {
const { timer } = this.state
clearInterval(timer)
}
render() {
const {
hasSynced,
syncStatus,
syncPercentage,
address,
blockHeight,
lndBlockHeight,
lndCfilterHeight,
intl,
theme
} = this.props
let { syncMessageDetail, syncMessageExtraDetail } = this.state
if (syncStatus === 'complete') {
return