[local-sync] protection from reset action being double-fired

Summary: Double-firing protection since the DatabaseStore can now fire this

Test Plan: manual

Reviewers: juan

Reviewed By: juan

Differential Revision: https://phab.nylas.com/D3730
This commit is contained in:
Evan Morikawa 2017-01-18 17:30:30 -08:00
parent 02cf6fbf6e
commit a124b6c100

View file

@ -36,11 +36,14 @@ class SyncProcessManager {
Actions.wakeLocalSyncWorkerForAccount.listen((accountId) => Actions.wakeLocalSyncWorkerForAccount.listen((accountId) =>
this.wakeWorkerForAccount(accountId) this.wakeWorkerForAccount(accountId)
) );
this._resettingEmailCache = false
Actions.resetEmailCache.listen(this._resetEmailCache, this) Actions.resetEmailCache.listen(this._resetEmailCache, this)
} }
_resetEmailCache() { _resetEmailCache() {
if (this._resettingEmailCache) return;
this._resettingEmailCache = true
try { try {
for (const worker of this.workers()) { for (const worker of this.workers()) {
worker.stopSync() worker.stopSync()
@ -57,6 +60,7 @@ class SyncProcessManager {
}, 100) }, 100)
} catch (err) { } catch (err) {
console.error(err) console.error(err)
this._resettingEmailCache = false
} }
} }