Fix bug where sync could spawn twice

This commit is contained in:
Ben Gotow 2017-09-07 02:36:53 -07:00
parent 2b9e96fc72
commit f0401a7ba1

View file

@ -200,13 +200,6 @@ export default class MailsyncBridge {
return;
}
if (fullAccountJSON.syncState !== Account.SYNC_STATE_OK) {
Actions.updateAccount(id, {
syncState: Account.SYNC_STATE_OK,
syncError: null,
});
}
const client = new MailsyncProcess(NylasEnv.getLoadSettings(), identity, fullAccountJSON);
client.sync();
client.on('deltas', this._onIncomingMessages);
@ -232,6 +225,14 @@ export default class MailsyncBridge {
}
});
this._clients[id] = client;
if (fullAccountJSON.syncState !== Account.SYNC_STATE_OK) {
// note: This call triggers ensureClients, and must go after this.clients[id] is set
Actions.updateAccount(id, {
syncState: Account.SYNC_STATE_OK,
syncError: null,
});
}
}
_onQueueTask(task) {