... | ... |
@@ -10,26 +10,18 @@ class Xmpp.Models.Chat extends Xmpp.Models.Model |
10 | 10 |
|
11 | 11 |
class Xmpp.Collections.ChatsCollection extends Backbone.Collection |
12 | 12 |
model: Xmpp.Models.Chat |
13 |
- openedChats: [] |
|
14 | 13 |
|
15 | 14 |
initialize: -> |
16 | 15 |
_.bindAll(this) |
17 | 16 |
|
18 |
- @on('add', @newChat) |
|
19 | 17 |
Backbone.Events.on('closeChat', (tab, chat) => |
20 | 18 |
@removeChat(chat) |
21 | 19 |
) |
22 | 20 |
|
23 |
- newChat: (chat) -> |
|
24 |
-# App.debug ['adding chat to chatCollection', chat] |
|
25 |
- @openedChats.push chat |
|
26 |
- |
|
27 | 21 |
find: (who, withWhom) -> |
28 |
-# App.debug ['opened chats:', @openedChats] |
|
29 |
- |
|
30 |
- _.find(@openedChats, (chat) -> |
|
22 |
+ _.find(@models, (chat) -> |
|
31 | 23 |
chat.get('who') == who && chat.get('withWhom') == withWhom |
32 | 24 |
) |
33 | 25 |
|
34 | 26 |
removeChat: (chat) -> |
35 |
- @openedChats = _.without(@openedChats, chat) |
|
36 | 27 |
\ No newline at end of file |
28 |
+ @models = _.without(@openedChats, chat) |
|
37 | 29 |
\ No newline at end of file |