fix(sync): Request all labels / folders to avoid paging and missing inbox

This commit is contained in:
Ben Gotow 2015-10-03 23:53:59 -07:00
parent ecf557ce31
commit 272d9514ca
5 changed files with 10 additions and 6 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.7 KiB

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 271 KiB

After

Width:  |  Height:  |  Size: 3.8 KiB

View file

@ -94,9 +94,9 @@ class NylasSyncWorker
@fetchCollection('threads')
if @_account.usesLabels()
@fetchCollection('labels')
@fetchCollection('labels', {initialPageSize: 1000})
if @_account.usesFolders()
@fetchCollection('folders')
@fetchCollection('folders', {initialPageSize: 1000})
@fetchCollection('drafts')
@fetchCollection('contacts')
@fetchCollection('calendars')
@ -116,7 +116,10 @@ class NylasSyncWorker
@writeState()
@fetchCollectionCount(model)
@fetchCollectionPage(model, {offset: 0, limit: INITIAL_PAGE_SIZE})
@fetchCollectionPage(model, {
limit: options.initialPageSize ? INITIAL_PAGE_SIZE,
offset: 0
})
fetchCollectionCount: (model) ->
@_api.makeRequest

View file

@ -62,6 +62,10 @@ describe "NylasSyncWorker", ->
expect(modelsRequested).toEqual(['threads', 'labels', 'drafts', 'contacts', 'events'])
expect(countsRequested).toEqual(['/threads', '/labels', '/drafts', '/contacts', '/events'])
fit "should fetch 1000 labels and folders, to prevent issues where Inbox is not in the first page", ->
labelsRequest = _.find @apiRequests, (r) -> r.model is 'labels'
expect(labelsRequest.params.limit).toBe(1000)
it "should mark incomplete collections as `busy`", ->
@worker.start()
advanceClock()
@ -102,7 +106,6 @@ describe "NylasSyncWorker", ->
advanceClock(30000); expect(@worker.resumeFetches.callCount).toBe(5)
it "handles the request as a failure if we try and grab labels or folders without an 'inbox'", ->
spyOn(@worker, 'resumeFetches').andCallThrough()
@worker.start()
expect(@worker.resumeFetches.callCount).toBe(1)
@ -113,7 +116,6 @@ describe "NylasSyncWorker", ->
expect(@worker.resumeFetches.callCount).toBe(2)
it "handles the request as a success if we try and grab labels or folders and it includes the 'inbox'", ->
spyOn(@worker, 'resumeFetches').andCallThrough()
@worker.start()
expect(@worker.resumeFetches.callCount).toBe(1)

View file

@ -55,7 +55,6 @@ describe "NylasAPI", ->
expect(Actions.postNotification.mostRecentCall.args[0].message).toEqual("Nylas can no longer authenticate with your mail provider. You will not be able to send or receive mail. Please unlink your account and sign in again.")
describe "handleModelResponse", ->
beforeEach ->
spyOn(DatabaseStore, "persistModels").andCallFake (models) ->
Promise.resolve(models)