fix(nylas-api): Fix broken promise logic in NylasAPI success/error blocks

- Restores file uploading / canceling behavior
This commit is contained in:
Ben Gotow 2015-07-21 18:14:19 -07:00
parent 45e27d7ded
commit 8874874c27
3 changed files with 5 additions and 8 deletions

View file

@ -187,20 +187,20 @@ class NylasAPI
success = (body) =>
if options.beforeProcessing
body = options.beforeProcessing(body)
return Promise.resolve(body)
if options.returnsModel
@_handleModelResponse(body).then (objects) ->
return Promise.resolve(body)
Promise.resolve(body)
error = (err) =>
handlePromise = Promise.resolve()
if err.response
handlePromise = Promise.resolve()
if err.response.statusCode is 404 and options.returnsModel
handlePromise = @_handleModel404(options.url)
if err.response.statusCode is 401
handlePromise = @_handle401(options.url)
handlePromise.then ->
Promise.reject(err)
handlePromise.finally ->
Promise.reject(err)
req = new NylasAPIRequest(@, options)
req.run().then(success, error)

View file

@ -44,10 +44,6 @@ class ChangeCategoryTask extends Task
if @threadIds.length > 0 then Klass = Thread
else if @messageIds.length > 0 then Klass = Message
DatabaseStore.find(Klass, objectId).then (object) =>
# Always apply our changes to a new copy of the thread.
# In some scenarios it may actually be frozen
object = new Klass(object)
# Mark that we are optimistically changing this model. This will prevent
# inbound delta syncs from changing it back to it's old state. Only the
# operation that changes `optimisticChangeCount` back to zero will

View file

@ -1,4 +1,5 @@
_ = require 'underscore'
Task = require './task'
Label = require '../models/label'
Thread = require '../models/thread'
Message = require '../models/message'