diff --git a/packages/client-app/internal_packages/deltas/lib/contact-rankings-cache.es6 b/packages/client-app/internal_packages/deltas/lib/contact-rankings-cache.es6 index e8f3a905e..32f8fd888 100644 --- a/packages/client-app/internal_packages/deltas/lib/contact-rankings-cache.es6 +++ b/packages/client-app/internal_packages/deltas/lib/contact-rankings-cache.es6 @@ -24,7 +24,6 @@ class ContactRankingsCache extends RefreshingJSONCache { options: { accountId: this._accountId, path: "/contacts/rankings", - returnsModel: false, }, }) diff --git a/packages/client-app/internal_packages/onboarding/lib/onboarding-helpers.es6 b/packages/client-app/internal_packages/onboarding/lib/onboarding-helpers.es6 index 4297f1890..fe2223d2d 100644 --- a/packages/client-app/internal_packages/onboarding/lib/onboarding-helpers.es6 +++ b/packages/client-app/internal_packages/onboarding/lib/onboarding-helpers.es6 @@ -136,7 +136,6 @@ export function runAuthRequest(accountInfo) { timeout: 1000 * 90, // Connecting to IMAP could take up to 90 seconds, so we don't want to hang up too soon body: data, auth: noauth, - returnsModel: false, }, }) return n1CloudIMAPAuthRequest.run().then((remoteJSON) => { @@ -148,7 +147,6 @@ export function runAuthRequest(accountInfo) { timeout: 1000 * 90, // Connecting to IMAP could take up to 90 seconds, so we don't want to hang up too soon body: data, auth: noauth, - returnsModel: false, }, }) return localSyncIMAPAuthRequest.run().then((localJSON) => { diff --git a/packages/client-app/spec/nylas-api-spec.coffee b/packages/client-app/spec/nylas-api-spec.coffee index 774a7cedf..fdb2115ea 100644 --- a/packages/client-app/spec/nylas-api-spec.coffee +++ b/packages/client-app/spec/nylas-api-spec.coffee @@ -281,7 +281,6 @@ describe "NylasAPI", -> expect(this.options.path).toBe "/drafts/#{draft.serverId}" expect(this.options.accountId).toBe TEST_ACCOUNT_ID expect(this.options.method).toBe "DELETE" - expect(this.options.returnsModel).toBe false NylasAPIHelpers.makeDraftDeletionRequest(draft) it "should increment the change tracker, preventing any further deltas about the draft", -> diff --git a/packages/client-app/spec/tasks/send-draft-task-spec.es6 b/packages/client-app/spec/tasks/send-draft-task-spec.es6 index fea2bc8a6..0f325cd22 100644 --- a/packages/client-app/spec/tasks/send-draft-task-spec.es6 +++ b/packages/client-app/spec/tasks/send-draft-task-spec.es6 @@ -120,14 +120,6 @@ xdescribe('SendDraftTask', function sendDraftTask() { })); }); - it("should pass returnsModel:false", () => { - waitsForPromise(() => this.task.performRemote().then(() => { - expect(NylasAPIRequest.prototype.run.calls.length).toBe(1); - const options = NylasAPIRequest.prototype.run.mostRecentCall.args[0]; - expect(options.returnsModel).toBe(false); - })); - }); - it("should always send the draft body in the request body (joined attribute check)", () => { waitsForPromise(() => this.task.performRemote().then(() => { expect(NylasAPIRequest.prototype.run.calls.length).toBe(1); diff --git a/packages/client-app/spec/tasks/syncback-draft-task-spec.es6 b/packages/client-app/spec/tasks/syncback-draft-task-spec.es6 index 8b0868b1b..f132f17d4 100644 --- a/packages/client-app/spec/tasks/syncback-draft-task-spec.es6 +++ b/packages/client-app/spec/tasks/syncback-draft-task-spec.es6 @@ -183,15 +183,6 @@ xdescribe('SyncbackDraftTask', function syncbackDraftTask() { })); }); - it("should pass returnsModel:false so that the draft can be manually removed/added to the database, accounting for its ID change", () => { - const task = new SyncbackDraftTask("localDraftId"); - waitsForPromise(() => task.performRemote().then(() => { - expect(NylasAPIRequest.prototype.run).toHaveBeenCalled(); - const options = NylasAPIRequest.prototype.run.mostRecentCall.args[0]; - expect(options.returnsModel).toBe(false); - })); - }); - it("should save metadata associated with the draft when the draft has been already saved to the api", () => { const draft = remoteDraft(); draft.pluginMetadata = [{pluginId: 1, value: {a: 1}}]; diff --git a/packages/client-app/spec/tasks/syncback-model-task-spec.es6 b/packages/client-app/spec/tasks/syncback-model-task-spec.es6 index 74cee6f8f..f971872d5 100644 --- a/packages/client-app/spec/tasks/syncback-model-task-spec.es6 +++ b/packages/client-app/spec/tasks/syncback-model-task-spec.es6 @@ -147,7 +147,6 @@ xdescribe('SyncbackModelTask', function syncbackModelTask() { expect(opts.path).toBe("/test") expect(opts.method).toBe("POST") expect(opts.accountId).toBe("account-123") - expect(opts.returnsModel).toBe(false) expect(opts.body).toEqual(this.testModel.toJSON()) }); }); diff --git a/packages/client-app/src/flux/syncback-task-api-request.es6 b/packages/client-app/src/flux/syncback-task-api-request.es6 index 04bcdeeb5..79cf1a25d 100644 --- a/packages/client-app/src/flux/syncback-task-api-request.es6 +++ b/packages/client-app/src/flux/syncback-task-api-request.es6 @@ -2,6 +2,7 @@ import Actions from './actions' import {APIError} from './errors' import DatabaseStore from './stores/database-store' import NylasAPIRequest from './nylas-api-request' +import NylasAPIHelpers from './nylas-api-helpers' import ProviderSyncbackRequest from './models/provider-syncback-request' /** @@ -61,7 +62,6 @@ class SyncbackTaskAPIRequest { } constructor({api, options}) { - options.returnsModel = true this._request = new NylasAPIRequest({api, options}) this._onSyncbackRequestCreated = options.onSyncbackRequestCreated || (() => {}) } @@ -69,12 +69,16 @@ class SyncbackTaskAPIRequest { run() { return new Promise(async (resolve, reject) => { try { - const syncbackRequest = await this._request.run() + const syncbackRequest = await this._request.run(); + await NylasAPIHelpers.handleModelResponse(syncbackRequest) await this._onSyncbackRequestCreated(syncbackRequest) const syncbackRequestId = syncbackRequest.id SyncbackTaskAPIRequest.listenForRequest(syncbackRequestId) .then(resolve).catch(reject) } catch (err) { + if (err.response && err.response.statusCode === 404) { + NylasAPIHelpers.handleModel404(this._request.options.url) + } reject(err) } }) diff --git a/packages/client-app/src/flux/tasks/change-mail-task.es6 b/packages/client-app/src/flux/tasks/change-mail-task.es6 index c9d6e2dd1..810b32483 100644 --- a/packages/client-app/src/flux/tasks/change-mail-task.es6 +++ b/packages/client-app/src/flux/tasks/change-mail-task.es6 @@ -231,7 +231,6 @@ export default class ChangeMailTask extends Task { accountId: model.accountId, method: 'PUT', body: this.requestBodyForModel(model), - returnsModel: true, onSyncbackRequestCreated: (syncbackRequest) => { if (!this._syncbackRequestIds) this._syncbackRequestIds = {} this._syncbackRequestIds[model.id] = syncbackRequest.id diff --git a/packages/client-app/src/flux/tasks/destroy-category-task.es6 b/packages/client-app/src/flux/tasks/destroy-category-task.es6 index 47c93c372..e42b7b596 100644 --- a/packages/client-app/src/flux/tasks/destroy-category-task.es6 +++ b/packages/client-app/src/flux/tasks/destroy-category-task.es6 @@ -64,7 +64,6 @@ export default class DestroyCategoryTask extends Task { accountId, path, method: 'DELETE', - returnsModel: false, onSyncbackRequestCreated: (syncbackRequest) => { this._syncbackRequestId = syncbackRequest.id }, diff --git a/packages/client-app/src/flux/tasks/destroy-draft-task.es6 b/packages/client-app/src/flux/tasks/destroy-draft-task.es6 index 5e12d3655..8d2e77432 100644 --- a/packages/client-app/src/flux/tasks/destroy-draft-task.es6 +++ b/packages/client-app/src/flux/tasks/destroy-draft-task.es6 @@ -45,7 +45,6 @@ export default class DestroyDraftTask extends BaseDraftTask { body: { version: this.draft.version, }, - returnsModel: false, }, }) .run() diff --git a/packages/client-app/src/flux/tasks/event-rsvp-task.es6 b/packages/client-app/src/flux/tasks/event-rsvp-task.es6 index fe0d8a54a..a05fc00d0 100644 --- a/packages/client-app/src/flux/tasks/event-rsvp-task.es6 +++ b/packages/client-app/src/flux/tasks/event-rsvp-task.es6 @@ -46,7 +46,6 @@ export default class EventRSVPTask extends Task { event_id: id, status: this.RSVPResponse, }, - returnsModel: true, }, }) .run() diff --git a/packages/client-app/src/flux/tasks/syncback-category-task.es6 b/packages/client-app/src/flux/tasks/syncback-category-task.es6 index 7defec1be..ce2c5328e 100644 --- a/packages/client-app/src/flux/tasks/syncback-category-task.es6 +++ b/packages/client-app/src/flux/tasks/syncback-category-task.es6 @@ -67,9 +67,6 @@ export default class SyncbackCategoryTask extends Task { body: { display_name: this.displayName || this.category.displayName, }, - // returnsModel must be false because we want to update the - // existing model rather than returning a new model. - returnsModel: false, onSyncbackRequestCreated: (syncbackRequest) => { this._syncbackRequestId = syncbackRequest.id }, diff --git a/packages/client-app/src/flux/tasks/syncback-draft-task.es6 b/packages/client-app/src/flux/tasks/syncback-draft-task.es6 index 46dc71dbb..e3f352664 100644 --- a/packages/client-app/src/flux/tasks/syncback-draft-task.es6 +++ b/packages/client-app/src/flux/tasks/syncback-draft-task.es6 @@ -21,7 +21,6 @@ export default class SyncbackDraftTask extends BaseDraftTask { path: (this.draft.serverId) ? `/drafts/${this.draft.serverId}` : "/drafts", method: (this.draft.serverId) ? 'PUT' : 'POST', body: this.draft.toJSON(), - returnsModel: false, }, }) .run() diff --git a/packages/client-app/src/flux/tasks/syncback-metadata-task.es6 b/packages/client-app/src/flux/tasks/syncback-metadata-task.es6 index 4e5875912..256233281 100644 --- a/packages/client-app/src/flux/tasks/syncback-metadata-task.es6 +++ b/packages/client-app/src/flux/tasks/syncback-metadata-task.es6 @@ -29,7 +29,6 @@ export default class SyncbackMetadataTask extends SyncbackModelTask { } const options = { accountId: model.accountId, - returnsModel: false, path: `/metadata/${model.serverId}/${this.pluginId}`, method: 'POST', body: { diff --git a/packages/client-app/src/flux/tasks/syncback-model-task.es6 b/packages/client-app/src/flux/tasks/syncback-model-task.es6 index 30aaee61a..e93dab2d0 100644 --- a/packages/client-app/src/flux/tasks/syncback-model-task.es6 +++ b/packages/client-app/src/flux/tasks/syncback-model-task.es6 @@ -53,7 +53,6 @@ export default class SyncbackModelTask extends Task { try { const options = _.extend({ accountId: model.accountId, - returnsModel: false, }, this.getRequestData(model)); return new NylasAPIRequest({ api: NylasAPI,