mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-03-11 15:34:27 +08:00
fix(sync): Request all labels / folders to avoid paging and missing inbox
This commit is contained in:
parent
84c8e2f99d
commit
308c70f53d
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 |
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue