From 05cb082e2f6b78c6f151f93dbc1835f735f4c093 Mon Sep 17 00:00:00 2001 From: yflory Date: Fri, 27 Mar 2020 15:16:17 +0100 Subject: [PATCH] Stop refreshing the usage bar if the tab is not visible --- www/common/common-ui-elements.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/www/common/common-ui-elements.js b/www/common/common-ui-elements.js index f535ad4a5..60a3bcfc5 100644 --- a/www/common/common-ui-elements.js +++ b/www/common/common-ui-elements.js @@ -15,12 +15,13 @@ define([ '/customize/pages.js', '/bower_components/nthen/index.js', '/common/inner/invitation.js', + '/common/visible.js', 'css!/customize/fonts/cptools/style.css', '/bower_components/croppie/croppie.min.js', 'css!/bower_components/croppie/croppie.css', ], function ($, Config, Util, Hash, Language, UI, Constants, Feedback, h, MediaTag, Clipboard, - Messages, AppConfig, Pages, NThen, InviteInner) { + Messages, AppConfig, Pages, NThen, InviteInner, Visible) { var UIElements = {}; // Configure MediaTags to use our local viewer @@ -2229,6 +2230,17 @@ define([ updateUsage(); }, LIMIT_REFRESH_RATE * 3); + Visible.onChange(function (state) { + if (!state) { + clearInterval(interval); + return; + } + interval = setInterval(function () { + updateUsage(); + }, LIMIT_REFRESH_RATE * 3); + updateUsage(); + }); + updateUsage(); cb(null, $container); return {