Skip to content

Commit

Permalink
[client-sync] Ensure allmail folder exists before trying to access it
Browse files Browse the repository at this point in the history
Summary:
When checking for flag updates for gmail accounts, when syncing for the
first time the all mail folder won't be available because we haven't
fetched the folder list, so it will throw a runtime error

Test Plan: manual

Reviewers: mark, halla

Reviewed By: halla

Differential Revision: https://phab.nylas.com/D4405
  • Loading branch information
jstejada committed Apr 11, 2017
1 parent d226eaf commit 0525767
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions packages/client-sync/src/local-sync-worker/sync-worker.es6
Original file line number Diff line number Diff line change
Expand Up @@ -293,9 +293,11 @@ class SyncWorker {
if (this._account.provider === "gmail") {
const checkForAttributeUpdates = async () => {
const allMailFolder = await this._db.Folder.findOne({where: {role: 'all'}})
const allMailBox = await this._mailListenerIMAPConn.getLatestBoxStatus(allMailFolder.name)
if (allMailFolder.syncState.highestmodseq !== allMailBox.highestmodseq) {
onUpdate();
if (allMailFolder) {
const allMailBox = await this._mailListenerIMAPConn.getLatestBoxStatus(allMailFolder.name)
if (allMailFolder.syncState.highestmodseq !== allMailBox.highestmodseq) {
onUpdate();
}
}
this._mailListenerAttrPollTimeout = setTimeout(checkForAttributeUpdates, 30 * 1000)
}
Expand Down

0 comments on commit 0525767

Please sign in to comment.