app/assets/javascripts/backbone/models/chat.js.coffee
6a6ccd01
 class Xmpp.Models.Chat extends Xmpp.Models.Model
   namespace: 'app.chat'
 
   defaults:
     who: null
     withWhom: null
2a61cdcc
     chatId: null
6a6ccd01
 
   initialize: ->
     _.bindAll(this)
 
31111b63
     #App.Com.openNewMultiChatId(@get('who').get('jid'), @get('withWhom').get('jid'), this)
2a61cdcc
 
   setChatId: (id) ->
     App.debug ['chat has id', id]
     @set('chatId', id)
 
6a6ccd01
 class Xmpp.Collections.ChatsCollection extends Backbone.Collection
   model: Xmpp.Models.Chat
 
   initialize: ->
     _.bindAll(this)
 
bcce524b
     Backbone.Events.on('closeChat', (tab, chat) =>
       @removeChat(chat)
     )
6a6ccd01
 
   find: (who, withWhom) ->
fcce5d56
     _.find(@models, (chat) ->
6a6ccd01
       chat.get('who') == who && chat.get('withWhom') == withWhom
     )
 
1f685c13
   findById: (id) ->
     @findWhere(chatId: id)
 
6a6ccd01
   removeChat: (chat) ->
fcce5d56
     @models = _.without(@openedChats, chat)