From 00f4de3c5176b0f90d3bc8758ba648863174c979 Mon Sep 17 00:00:00 2001 From: Tristan Cacqueray Date: Tue, 12 Feb 2019 14:10:32 +0000 Subject: [PATCH] web: prevent status update loop in background When leaving the status page while it is waiting for status data, the callback happens when the status page is not mounted, resulting in the update loop timer not being cleared. This change prevents that by setting the visible attribute to false when leaving the page, so that the update is not scheduled when the page is not visible. Change-Id: I9f3db68bb77c52d0f477b8322bbf52bd3cc81fe1 --- web/src/pages/Status.jsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/web/src/pages/Status.jsx b/web/src/pages/Status.jsx index 2003ecac8c..2328ccadb3 100644 --- a/web/src/pages/Status.jsx +++ b/web/src/pages/Status.jsx @@ -84,7 +84,7 @@ class StatusPage extends Refreshable { updateData = (force) => { if (force || (this.visible && this.state.autoReload)) { this.props.dispatch(fetchStatusIfNeeded(this.props.tenant)) - .then(() => {if (this.state.autoReload) { + .then(() => {if (this.state.autoReload && this.visible) { this.timer = setTimeout(this.updateData, 5000) }}) } @@ -106,6 +106,7 @@ class StatusPage extends Refreshable { clearTimeout(this.timer) this.timer = null } + this.visible = false document.removeEventListener( this.visibilityChangeEvent, this.visibilityListener) }