fix(offline): /Generally/ a timeout is a temporary error code. Only SendDraftTask should bail and tell the user the draft failed to send

This commit is contained in:
Ben Gotow 2015-09-11 15:14:52 -07:00
parent 45fa6d0a8b
commit 525e1419e3
4 changed files with 11 additions and 3 deletions

View file

@ -20,8 +20,9 @@ class ComposerWithWindowProps extends React.Component
componentDidMount: ->
@unlisten = atom.onWindowPropsReceived (windowProps) =>
{errorMessage} = windowProps
@_showInitialErrorDialog(errorMessage) if errorMessage
@setState(windowProps)
if errorMessage
@_showInitialErrorDialog(errorMessage)
componentWillUnmount: ->
@unlisten()

View file

@ -10,7 +10,7 @@ async = require 'async'
# A 0 code is when an error returns without a status code. These are
# things like "ESOCKETTIMEDOUT"
TimeoutErrorCode = 0
PermanentErrorCodes = [400, 404, 500, TimeoutErrorCode]
PermanentErrorCodes = [400, 404, 500]
CancelledErrorCode = -123
SampleTemporaryErrorCode = 504

View file

@ -10,6 +10,12 @@ class ChangeStarredTask extends ChangeMailTask
constructor: ({@starred}={}) ->
super
label: ->
if @starred
"Starring…"
else
"Unstarring…"
description: ->
count = @threads.length
type = 'thread'

View file

@ -89,7 +89,8 @@ class SendDraftTask extends Task
body.thread_id = null
body.reply_to_message_id = null
return @_send(body)
else if err.statusCode in NylasAPI.PermanentErrorCodes
else if (err.statusCode in NylasAPI.PermanentErrorCodes or
err.statusCode is NylasAPI.TimeoutErrorCode)
@_permanentError()
else
return Promise.resolve(Task.Status.Retry)