 
             @props.isSaving = false
 
-    onDelete: (e) ->
-        e.preventDefault()
-
-        subject = @props.message.get 'subject'
-        if subject? and subject isnt ''
+    deleteDraft: (event) ->
+        event.preventDefault() if event
+
+        if _.isEmpty (subject = @state.subject)
             params = subject: subject
             confirmMessage = t 'mail confirm delete', params
         else
             confirmMessage = t 'mail confirm delete nosubject'
 
         doDelete = =>
-            LayoutActionCreator.hideModal()
-            messageID = @props.message.get('id')
-
-            # this will prevent asking
-            # a second time when unmounting component
-            @setState isDeleted: true, =>
-                MessageActionCreator.delete {messageID}, (error) =>
-                    unless error?
-                        if @props.callback
-                            @props.callback()
-                        else
-                            # Close Message Box
-                            @redirect
-                                direction: 'first'
-                                action: 'account.mailbox.messages'
-                                parameters: [
-                                    @props.selectedAccountID
-                                    @props.selectedMailboxID
-                                ]
-                                fullWidth: true
-
-        modal =
+            @redirect
+                direction: 'first'
+                action: 'account.mailbox.messages'
+                fullWidth: true
+                parameters: [
+                    @props.selectedAccountID
+                    @props.selectedMailboxID
+                ]
+
+        @showModal
             title       : t 'mail confirm delete title'
             subtitle    : confirmMessage
             closeLabel  : t 'mail confirm delete cancel'
             actionLabel : t 'mail confirm delete delete'
-            action      : doDelete
-        LayoutActionCreator.displayModal modal
-
+        , doDelete
 
     onToggleCc: (e) ->
         toggle = (e) -> e.classList.toggle 'shown'

            'subject': ['subject']
        getGroupedError error, @state

    getMessageFromDOM: ->
        state = _.clone @state
        message = {}

        from = {}
        account = @props.accounts.get @state.accountID
        from.name = name if (name = account.get 'name')
        from.address = address if (address = account.get 'login')
        message.from = [from]

        # TODO : get CC
        # TODO : get BCC
        # TODO : get TO

        _.extend state, message

    sendActionMessage: ->
        if (validate = @validateMessage())
            LayoutActionCreator.alertError t 'compose error no ' + validate[1]
            return

        message = @getMessageFromDOM()
        return unless (changed = hasChanged @state, message)

        @props.isSaving = true
        MessageActionCreator.send message, (error, message) =>

                , 0
                @setState focus: ''

    showModal: (params, success) ->
        return unless @state.originalConversationID

        doDelete = =>
            messageID = @state.id
            MessageActionCreator.delete {messageID}
            LayoutActionCreator.hideModal()

            if @props.callback
                @props.callback()
                return

            # specific callback
            success() if _.isFunction success

        _.extend params, action: doDelete
        LayoutActionCreator.displayModal params

    componentWillUnmount: ->
        doSave = =>
            LayoutActionCreator.hideModal()
            MessageActionCreator.send @state, (error, message) ->
                if error? or not message?
                    msg = "#{t "message action draft ko"} #{error}"
                    LayoutActionCreator.alertError msg
                    return

                msg = "#{t "message action draft ok"}"
                LayoutActionCreator.notify msg, autoclose: true

                # reload conversation to update its length
                if message.conversationID?
                    cid = message.conversationID
                    MessageActionCreator.fetchConversation cid

        init = =>
            @showModal
                title       : t 'app confirm delete'
                subtitle    : t 'compose confirm keep draft'
                closeLabel  : t 'compose confirm draft keep'
                actionLabel : t 'compose confirm draft delete'
                closeModal  : doSave

        setTimeout init, 0

    getInitialState: ->
        # edition of an existing draft
        if message = @props.message
            state =
                composeInHTML: @props.settings.get 'composeInHTML'
            if (not message.get('html')?) and message.get('text')
                state.composeInHTML = false

