mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-01-09 09:38:07 +08:00
Fixes to sync worker
This commit is contained in:
parent
ca0120a824
commit
2d90c5bb14
1 changed files with 15 additions and 12 deletions
|
@ -52,13 +52,17 @@ class SyncWorker {
|
|||
}
|
||||
|
||||
_onAccountUpdated() {
|
||||
console.log("SyncWorker: Detected change to account. Reloading and syncing now.")
|
||||
DatabaseConnector.forShared().then(({Account}) => {
|
||||
Account.find({where: {id: this._account.id}}).then((account) => {
|
||||
this._account = account;
|
||||
this.syncNow();
|
||||
})
|
||||
});
|
||||
console.log("SyncWorker: Detected change to account. Reloading and syncing now.");
|
||||
this._getAccount().then((account) => {
|
||||
this._account = account;
|
||||
this.syncNow();
|
||||
})
|
||||
}
|
||||
|
||||
_getAccount() {
|
||||
return DatabaseConnector.forShared().then(({Account}) =>
|
||||
Account.find({where: {id: this._account.id}})
|
||||
);
|
||||
}
|
||||
|
||||
onSyncDidComplete() {
|
||||
|
@ -122,16 +126,15 @@ class SyncWorker {
|
|||
}
|
||||
|
||||
syncbackMessageActions() {
|
||||
const {SyncbackRequest, accountId, Account} = this._db;
|
||||
return this._db.Account.find({where: {id: accountId}}).then((account) => {
|
||||
return Promise.each(SyncbackRequest.findAll().then((reqs = []) =>
|
||||
return this._getAccount((account) =>
|
||||
Promise.each(this._db.SyncbackRequest.findAll().then((reqs = []) =>
|
||||
reqs.map((request) => {
|
||||
const task = SyncbackTaskFactory.create(account, request);
|
||||
if (!task) return Promise.reject("No Task")
|
||||
return this._conn.runOperation(task)
|
||||
})
|
||||
));
|
||||
});
|
||||
))
|
||||
)
|
||||
}
|
||||
|
||||
syncAllCategories() {
|
||||
|
|
Loading…
Reference in a new issue