Reduce offline battery usage by… updating labels less often

This commit is contained in:
Ben Gotow 2017-12-01 10:18:15 -08:00
parent 62aab65db4
commit e454f9d608

View file

@ -62,6 +62,15 @@ class OnlineStatusStore extends MailspringStore {
if (this._countdownSeconds === 0) { if (this._countdownSeconds === 0) {
this._checkOnlineStatus(); this._checkOnlineStatus();
} else { } 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 }); this.trigger({ onlineDidChange: false, countdownDidChange: true });
} }
}, 1000); }, 1000);