mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-09-22 08:16:09 +08:00
fix(nylas-api): Fix broken promise logic in NylasAPI success/error blocks
- Restores file uploading / canceling behavior
This commit is contained in:
parent
45e27d7ded
commit
8874874c27
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
_ = require 'underscore'
|
||||
Task = require './task'
|
||||
Label = require '../models/label'
|
||||
Thread = require '../models/thread'
|
||||
Message = require '../models/message'
|
||||
|
|
Loading…
Reference in a new issue