mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-09-11 23:24:32 +08:00
Revert "[client-sync] Poll for gmail attribute changes from _mailListenerIMAPConn
"
This reverts commit 15c3e328fc
.
See https://phab.nylas.com/D4410 for details on why it was reverted
This commit is contained in:
parent
1bf453dd4a
commit
811843f880
1 changed files with 4 additions and 27 deletions
|
@ -22,6 +22,7 @@ import SyncTaskFactory from './sync-task-factory';
|
|||
import SyncbackTaskRunner from './syncback-task-runner'
|
||||
import SyncActivity from '../shared/sync-activity'
|
||||
|
||||
|
||||
const {SYNC_STATE_RUNNING, SYNC_STATE_AUTH_FAILED, SYNC_STATE_ERROR} = Account
|
||||
const AC_SYNC_LOOP_INTERVAL_MS = 10 * 1000 // 10 sec
|
||||
const BATTERY_SYNC_LOOP_INTERVAL_MS = 5 * 60 * 1000 // 5 min
|
||||
|
@ -52,7 +53,6 @@ class SyncWorker {
|
|||
this._latestOpenTimesByFolder = new Map();
|
||||
this._mainIMAPConnDisposer = null
|
||||
this._mailListenerIMAPConnDisposer = null
|
||||
this._mailListenerAttrPollTimeout = null;
|
||||
|
||||
this._retryScheduler = new ExponentialBackoffScheduler({
|
||||
baseDelay: 15 * 1000,
|
||||
|
@ -276,34 +276,15 @@ class SyncWorker {
|
|||
this._onInboxUpdates(`You've got mail`);
|
||||
})
|
||||
|
||||
const onUpdate = () => {
|
||||
// TODO Gmail does not emit `update` events
|
||||
this._mailListenerIMAPConn.on('update', () => {
|
||||
// `update` events happen when messages receive flag updates on the inbox
|
||||
// (e.g. marking as unread or starred). We need to listen to that event for
|
||||
// when those updates are performed from another mail client, but ignore
|
||||
// them when they are caused from within N1.
|
||||
if (this._shouldIgnoreInboxFlagUpdates) { return; }
|
||||
this._onInboxUpdates(`There are flag updates on the inbox`);
|
||||
}
|
||||
|
||||
this._mailListenerIMAPConn.on('update', onUpdate)
|
||||
|
||||
// Gmail actually only emits 'update' events when there are new or
|
||||
// removed messages. We have to periodically check the highestmodseq to
|
||||
// see if there have been any flag changes.
|
||||
if (this._account.provider === "gmail") {
|
||||
const checkForAttributeUpdates = async () => {
|
||||
const allMailFolder = await this._db.Folder.findOne({where: {role: 'all'}})
|
||||
if (allMailFolder) {
|
||||
const allMailBox = await this._mailListenerIMAPConn.getLatestBoxStatus(allMailFolder.name)
|
||||
if (allMailFolder.syncState.highestmodseq !== allMailBox.highestmodseq) {
|
||||
onUpdate();
|
||||
}
|
||||
}
|
||||
this._mailListenerAttrPollTimeout = setTimeout(checkForAttributeUpdates, 30 * 1000)
|
||||
}
|
||||
checkForAttributeUpdates()
|
||||
}
|
||||
|
||||
})
|
||||
return true
|
||||
},
|
||||
})
|
||||
|
@ -343,10 +324,6 @@ class SyncWorker {
|
|||
this._mailListenerIMAPConnDisposer()
|
||||
this._mailListenerIMAPConnDisposer = null
|
||||
}
|
||||
if (this._mailListenerAttrPollTimeout) {
|
||||
clearTimeout(this._mailListenerAttrPollTimeout)
|
||||
this._mailListenerAttrPollTimeout = null
|
||||
}
|
||||
}
|
||||
|
||||
async _getFoldersToSync() {
|
||||
|
|
Loading…
Add table
Reference in a new issue