Stop refreshing the usage bar if the tab is not visible

pull/1/head
yflory 5 years ago
parent 980baf9ce3
commit 05cb082e2f

@ -15,12 +15,13 @@ define([
'/customize/pages.js', '/customize/pages.js',
'/bower_components/nthen/index.js', '/bower_components/nthen/index.js',
'/common/inner/invitation.js', '/common/inner/invitation.js',
'/common/visible.js',
'css!/customize/fonts/cptools/style.css', 'css!/customize/fonts/cptools/style.css',
'/bower_components/croppie/croppie.min.js', '/bower_components/croppie/croppie.min.js',
'css!/bower_components/croppie/croppie.css', 'css!/bower_components/croppie/croppie.css',
], function ($, Config, Util, Hash, Language, UI, Constants, Feedback, h, MediaTag, Clipboard, ], function ($, Config, Util, Hash, Language, UI, Constants, Feedback, h, MediaTag, Clipboard,
Messages, AppConfig, Pages, NThen, InviteInner) { Messages, AppConfig, Pages, NThen, InviteInner, Visible) {
var UIElements = {}; var UIElements = {};
// Configure MediaTags to use our local viewer // Configure MediaTags to use our local viewer
@ -2229,6 +2230,17 @@ define([
updateUsage(); updateUsage();
}, LIMIT_REFRESH_RATE * 3); }, LIMIT_REFRESH_RATE * 3);
Visible.onChange(function (state) {
if (!state) {
clearInterval(interval);
return;
}
interval = setInterval(function () {
updateUsage();
}, LIMIT_REFRESH_RATE * 3);
updateUsage();
});
updateUsage(); updateUsage();
cb(null, $container); cb(null, $container);
return { return {

Loading…
Cancel
Save