From 85f84688f33a0b6366538b38c279590f3a896c33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Renaudeau?= Date: Thu, 21 Jun 2018 12:38:22 +0200 Subject: [PATCH] don't spam dashboard check --- src/components/Workflow/EnsureDashboard.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/components/Workflow/EnsureDashboard.js b/src/components/Workflow/EnsureDashboard.js index 5d29f2e3..e7b86416 100644 --- a/src/components/Workflow/EnsureDashboard.js +++ b/src/components/Workflow/EnsureDashboard.js @@ -42,21 +42,20 @@ class EnsureDashboard extends PureComponent { componentDidMount() { this.checkForDashboard() - this._interval = setInterval(this.checkForDashboard, 1000) } - componentDidUpdate() { - this.checkForDashboard() + componentDidUpdate({ device }: Props) { + if (this.props.device !== device && this.props.device) { + this.checkForDashboard() + } } componentWillUnmount() { this._unmounting = true - clearInterval(this._interval) } _checking = false _unmounting = false - _interval: * checkForDashboard = async () => { const { device } = this.props