diff --git a/app/components/with-daemon-status-check.js b/app/components/with-daemon-status-check.js index 26679e0..7275db3 100644 --- a/app/components/with-daemon-status-check.js +++ b/app/components/with-daemon-status-check.js @@ -21,14 +21,7 @@ export const withDaemonStatusCheck = ( componentDidMount() { this.runTest(); - this.timer = setInterval(() => this.runTest(), 3000); - } - - componentDidUpdate(prevProps: Props, prevState: State) { - if (!prevState.isRunning && this.state.isRunning && this.timer) { - clearInterval(this.timer); - this.timer = null; - } + this.timer = setInterval(this.runTest, 2000); } componentWillUnmount() { @@ -38,11 +31,17 @@ export const withDaemonStatusCheck = ( } } - runTest() { + runTest = () => { rpc.getinfo().then((response) => { - if (response) this.setState(() => ({ isRunning: true })); + if (response) { + this.setState(() => ({ isRunning: true })); + if (this.timer) { + clearInterval(this.timer); + this.timer = null; + } + } }); - } + }; render() { if (this.state.isRunning) {