   newMessage: (message) ->
     @chatController.getListView().addItem message
 
+  isActive: ->
+    @getDomElement().hasClass "active"
+
+  setUnreadCount: (count) ->
+    if count > 0
+      title = "#{@name} (<span class='unread'>#{count}</span>)"
+    else
+      title = "#{@name}"
+
+    @tabHandle.getDomElement().find("b").html title
+
 class ChatListItemView extends KDListItemView
   viewAppended: ->
     @setTemplate @pistachio()

        @broadcastOwnMessage messageBody, PUBLIC, name

    # Delegates to the channel to handle received message
    @broadcaster.on channelName, (msg) =>
      @deliverMessageToChannel channel, msg

    @channels[name] = channel


  loadView:(mainView)->
    @joinChannel "@#{@username}"
    @joinChannel PUBLIC

  joinChannel: (name) ->
    view = @getOptions().view
    channelPaneInstance = view.addChannelTab name

    if channel = @channels[name]      
      return channel

    # When the tab is closed, remove the channel reference
    # and sign the user off from the channel
