[client-app] Don't try to restart sync on every IdentityStore change

Summary:
The IdentityStore can trigger any number of times, but we only want to
start sync if we previously didn't have an identity available

Test Plan: manual

Reviewers: spang, evan, halla

Reviewed By: evan, halla

Differential Revision: https://phab.nylas.com/D4246
This commit is contained in:
Juan Tejada 2017-03-21 11:10:51 -07:00
parent 43738771ac
commit 41ad424752

View file

@ -10,6 +10,7 @@ class SyncProcessManager {
constructor() {
this._exiting = false;
this._resettingEmailCache = false
this._identityId = null;
this._workersByAccountId = {};
this._localSyncDeltaEmittersByAccountId = new Map()
@ -32,7 +33,12 @@ class SyncProcessManager {
}
_onIdentityChanged() {
if (IdentityStore.identity()) {
this._identityId = IdentityStore.identity()
const newIdentityId = IdentityStore.identityId()
if (newIdentityId !== this._identityId) {
// The IdentityStore can trigger any number of times, but we only want to
// start sync if we previously didn't have an identity available
this._identityId = newIdentityId
this.start()
}
}