     element = @messages.getElement()
     element.scrollTop = element.scrollHeight
 
+  isScrollTopAtBottom: ->
+    element = @messages.getElement()
+    height = parseInt window.getComputedStyle(element).height, 10
+    return (element.scrollTop + height) is element.scrollHeight
+
   pistachio: ->
     """
       {{> @dock}}

    @updateDate details.time
    @lastMessage = @lastChatItem.message
    @emit "NewChatItemCreated"
    @scrollToBottom()

  appendToChatItem: (params) ->
    {details}  = params

    params           = { details, ownerNickname, ownerAccount }
    @lastMessageBody = details.body

    if ownerNickname is KD.nick()
    then forceScrollToBottom = yes
    else forceScrollToBottom = @isScrollTopAtBottom()

    if @lastChatItemOwner is ownerNickname
      @appendToChatItem params
      @updateDate details.time
    else
      @createNewChatItem params

    @scrollToBottom()  if forceScrollToBottom

  createNewChatItem: (params) ->
    {details, ownerAccount, ownerNickname} = params
