From a24f67398e25b6763fd54b14adfc4150b94200c7 Mon Sep 17 00:00:00 2001 From: Ben Gotow Date: Thu, 10 Mar 2016 16:03:32 -0800 Subject: [PATCH] fix(sync): Do not paginate /metadata unless pluginsSupported --- .../worker-sync/lib/nylas-sync-worker.coffee | 5 ++++- .../worker-sync/spec/nylas-sync-worker-spec.coffee | 10 ++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/internal_packages/worker-sync/lib/nylas-sync-worker.coffee b/internal_packages/worker-sync/lib/nylas-sync-worker.coffee index 691a23c33..d9d01075b 100644 --- a/internal_packages/worker-sync/lib/nylas-sync-worker.coffee +++ b/internal_packages/worker-sync/lib/nylas-sync-worker.coffee @@ -139,7 +139,10 @@ class NylasSyncWorker console.log("Retrieved #{offset + data.length} metadata objects") finished() - makeMetadataRequest(0) + if @_api.pluginsSupported + makeMetadataRequest(0) + else + finished() shouldFetchCollection: (model) -> return false unless @_state diff --git a/internal_packages/worker-sync/spec/nylas-sync-worker-spec.coffee b/internal_packages/worker-sync/spec/nylas-sync-worker-spec.coffee index 95e5efbef..2fd60267a 100644 --- a/internal_packages/worker-sync/spec/nylas-sync-worker-spec.coffee +++ b/internal_packages/worker-sync/spec/nylas-sync-worker-spec.coffee @@ -7,6 +7,7 @@ describe "NylasSyncWorker", -> beforeEach -> @apiRequests = [] @api = + pluginsSupported: true accessTokenForAccountId: => '123' makeRequest: (requestOptions) => @@ -192,6 +193,15 @@ describe "NylasSyncWorker", -> fetchAllMetadataCallback() expect(@worker.fetchCollection.calls.length).not.toBe(0) + it "should not fetch metadata pages if pluginsSupported is false", -> + @api.pluginsSupported = false + spyOn(NylasSyncWorker.prototype, '_fetchWithErrorHandling') + spyOn(@worker, 'fetchCollection') + @worker._state = {} + @worker.resumeFetches() + expect(@worker._fetchWithErrorHandling).not.toHaveBeenCalled() + expect(@worker.fetchCollection.calls.length).not.toBe(0) + it "should fetch collections for which `shouldFetchCollection` returns true", -> spyOn(@worker, 'fetchCollection') spyOn(@worker, 'shouldFetchCollection').andCallFake (collection) =>