       return if data.session_id isnt @session.session_id
       @focus()
     )
+
+  onLayoutChange: =>
+    @scrollToBottom()
 
   render: ->
     @html App.view('customer_chat/chat_window')

    scrollBottom = @scrollHolder.scrollTop() + @scrollHolder.height()
    @scrolledToBottom = Math.abs(scrollBottom - @scrollHolder.prop('scrollHeight')) <= @scrollSnapTolerance

  onScrollHintClick: ->
    # animate scroll
    @scrollHolder.animate({scrollTop: @scrollHolder.prop('scrollHeight')}, 300)
    @scrollHint.addClass('is-hidden')

  scrollToBottom: ->
    if @scrolledToBottom
      @scrollHolder.scrollTop(@scrollHolder.prop('scrollHeight'))
    else
      @scrollHint.removeClass('is-hidden')

class Setting extends App.ControllerModal
  buttonClose: true

      isNew: isNew
      timestamp: Date.now()

    @scrollToBottom showHint: true

  showWritingLoader: =>
    if !@isTyping
