mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-01-10 10:11:25 +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() {
|
_onAccountUpdated() {
|
||||||
console.log("SyncWorker: Detected change to account. Reloading and syncing now.")
|
console.log("SyncWorker: Detected change to account. Reloading and syncing now.");
|
||||||
DatabaseConnector.forShared().then(({Account}) => {
|
this._getAccount().then((account) => {
|
||||||
Account.find({where: {id: this._account.id}}).then((account) => {
|
this._account = account;
|
||||||
this._account = account;
|
this.syncNow();
|
||||||
this.syncNow();
|
})
|
||||||
})
|
}
|
||||||
});
|
|
||||||
|
_getAccount() {
|
||||||
|
return DatabaseConnector.forShared().then(({Account}) =>
|
||||||
|
Account.find({where: {id: this._account.id}})
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
onSyncDidComplete() {
|
onSyncDidComplete() {
|
||||||
|
@ -122,16 +126,15 @@ class SyncWorker {
|
||||||
}
|
}
|
||||||
|
|
||||||
syncbackMessageActions() {
|
syncbackMessageActions() {
|
||||||
const {SyncbackRequest, accountId, Account} = this._db;
|
return this._getAccount((account) =>
|
||||||
return this._db.Account.find({where: {id: accountId}}).then((account) => {
|
Promise.each(this._db.SyncbackRequest.findAll().then((reqs = []) =>
|
||||||
return Promise.each(SyncbackRequest.findAll().then((reqs = []) =>
|
|
||||||
reqs.map((request) => {
|
reqs.map((request) => {
|
||||||
const task = SyncbackTaskFactory.create(account, request);
|
const task = SyncbackTaskFactory.create(account, request);
|
||||||
if (!task) return Promise.reject("No Task")
|
if (!task) return Promise.reject("No Task")
|
||||||
return this._conn.runOperation(task)
|
return this._conn.runOperation(task)
|
||||||
})
|
})
|
||||||
));
|
))
|
||||||
});
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
syncAllCategories() {
|
syncAllCategories() {
|
||||||
|
|
Loading…
Reference in a new issue