From 845548584969ffae2ec825f8b9a0c41a78a8b5cc Mon Sep 17 00:00:00 2001 From: apanizo Date: Tue, 17 Apr 2018 17:12:00 +0200 Subject: [PATCH] WA-230 Introducing interval for checking balance every 1.5 second --- src/routes/safe/container/index.jsx | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/routes/safe/container/index.jsx b/src/routes/safe/container/index.jsx index 4b60b103..e4575fac 100644 --- a/src/routes/safe/container/index.jsx +++ b/src/routes/safe/container/index.jsx @@ -6,15 +6,25 @@ import Layout from '~/routes/safe/component/Layout' import selector, { type SelectorProps } from './selector' import actions, { type Actions } from './actions' -class SafeView extends React.PureComponent { - componentDidMount() { - const { safe, fetchBalance } = this.props - if (!safe) { return } +type Props = Actions & SelectorProps - const safeAddress: string = safe.get('address') - fetchBalance(safeAddress) +class SafeView extends React.PureComponent { + componentDidMount() { + this.intervalId = setInterval(() => { + const { safe, fetchBalance } = this.props + if (!safe) { return } + + const safeAddress: string = safe.get('address') + fetchBalance(safeAddress) + }, 1500) } + componentWillUnmount() { + clearInterval(this.intervalId) + } + + intervalId: IntervalID + render() { const { safe, provider, balance } = this.props