         if message.reply_to
           if message.ok
             console.log "Message "+message.reply_to+" was sent"
-            # TODO: Now add to history
+            if @_pending[message.reply_to]
+              m = @_pending[message.reply_to]
+              channel = @getChannelGroupOrDMByID m
+              if channel
+                channel.addMessage m
+
+              delete @_pending[message.reply_to]
           else
             console.error "Error sending message "+message.reply_to+": "+message.error.msg
             # TODO: resend?

    @socketUrl      = null
    @ws             = null
    @_messageID     = 0

  #
  # Logging in and connection management functions

      console.error "Cannot send when not connected"
    else
      message.id = ++@_messageID
      @_pending[message.id] = message
      @ws.send JSON.stringify(message)

  _apiCall: (method, params, callback) ->
