From e454f9d608338e541dcd7aba483a9b20186304c7 Mon Sep 17 00:00:00 2001 From: Ben Gotow Date: Fri, 1 Dec 2017 10:18:15 -0800 Subject: [PATCH] =?UTF-8?q?Reduce=20offline=20battery=20usage=20by?= =?UTF-8?q?=E2=80=A6=20updating=20labels=20less=20often?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/flux/stores/online-status-store.es6 | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/app/src/flux/stores/online-status-store.es6 b/app/src/flux/stores/online-status-store.es6 index 6f935f8da..1935655b2 100644 --- a/app/src/flux/stores/online-status-store.es6 +++ b/app/src/flux/stores/online-status-store.es6 @@ -62,6 +62,15 @@ class OnlineStatusStore extends MailspringStore { if (this._countdownSeconds === 0) { this._checkOnlineStatus(); } else { + // if the countdown is greater than 10 seconds we only update every 5 + // seconds just for a tiny, tiny offline performance improvement + // 45, 30, 15, 10, 9, 8, 7... + if (this._countdownSeconds > 30 && this._countdownSeconds % 15 !== 0) { + return; + } + if (this._countdownSeconds > 10 && this._countdownSeconds % 5 !== 0) { + return; + } this.trigger({ onlineDidChange: false, countdownDidChange: true }); } }, 1000);