mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-09-22 08:16:09 +08:00
[local-sync] Don't sync spam until everything else is synced
Summary: Addresses T7426 Test Plan: manual Reviewers: evan, spang Reviewed By: spang Differential Revision: https://phab.nylas.com/D3655
This commit is contained in:
parent
59b5961a6c
commit
238b79d06c
|
@ -346,10 +346,15 @@ class SyncWorker {
|
||||||
async _getFoldersToSync() {
|
async _getFoldersToSync() {
|
||||||
const {Folder} = this._db;
|
const {Folder} = this._db;
|
||||||
|
|
||||||
|
// Don't sync spam until everything else has been synced
|
||||||
|
const allFolders = await Folder.findAll();
|
||||||
|
const foldersExceptSpam = allFolders.filter((f) => f.role !== 'spam')
|
||||||
|
const shouldIncludeSpam = foldersExceptSpam.every((f) => f.isSyncComplete())
|
||||||
|
const foldersToSync = shouldIncludeSpam ? allFolders : foldersExceptSpam;
|
||||||
|
|
||||||
// TODO make sure this order is correct/ unit tests!!
|
// TODO make sure this order is correct/ unit tests!!
|
||||||
const folders = await Folder.findAll();
|
const priority = ['inbox', 'all', 'sent', 'drafts', 'trash', 'spam'].reverse();
|
||||||
const priority = ['inbox', 'all', 'drafts', 'sent', 'trash', 'spam'].reverse();
|
return foldersToSync.sort((a, b) =>
|
||||||
return folders.sort((a, b) =>
|
|
||||||
(priority.indexOf(a.role) - priority.indexOf(b.role)) * -1
|
(priority.indexOf(a.role) - priority.indexOf(b.role)) * -1
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -424,12 +429,6 @@ class SyncWorker {
|
||||||
const interval = shouldSyncImmediately ? 1 : intervals.active;
|
const interval = shouldSyncImmediately ? 1 : intervals.active;
|
||||||
const nextSyncIn = Math.max(1, this._lastSyncTime + interval - Date.now())
|
const nextSyncIn = Math.max(1, this._lastSyncTime + interval - Date.now())
|
||||||
|
|
||||||
// this._logger.info({
|
|
||||||
// moreToSync,
|
|
||||||
// shouldSyncImmediately,
|
|
||||||
// interrupted: this._interrupted,
|
|
||||||
// nextSyncStartingIn: `${nextSyncIn}ms`,
|
|
||||||
// }, `SyncWorker: Scheduling next sync iteration`)
|
|
||||||
console.log(`🔃 🔜 in ${nextSyncIn}ms`)
|
console.log(`🔃 🔜 in ${nextSyncIn}ms`)
|
||||||
|
|
||||||
this._syncTimer = setTimeout(() => {
|
this._syncTimer = setTimeout(() => {
|
||||||
|
|
Loading…
Reference in a new issue