- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
this.listenTo(App.vent, 'chat:newMessage', function(data) {
if (!chatList.length && (data.Author.Id !== App.userModel.id)) {
this.addNewChat(UsersList.get(data.Author.Id));
this.createMessagesCollection(data.Author.Id);
App.allMessages[data.Author.Id].add(data);
this.addUnreadCount(data.Author.Id);
this.showAllChats();
this.showCurrentChat(App.allMessages[this.chatId]);
} else if (data.Author.Id !== App.userModel.id) {
this.addUnreadCount(data.Author.Id);
!App.allMessages[data.Author.Id] && this.createMessagesCollection(data.Author.Id);
App.allMessages[data.Author.Id].add(data);
this.showAllChats();
} else {
!App.allMessages[this.chatId] && this.createMessagesCollection(this.chatId);
App.allMessages[this.chatId].add(data);
this.showAllChats();
}
if (data.Author.Id !== App.userModel.id) {
App.vent.trigger("chat:newMessageToMe", data);
App.allMessages[self.chatId].readMessages();
setTimeout(function() {
chatList.get(self.chatId).set({
UnreadCount: 0
});
App.vent.trigger('chat:messagesread', self.chatId);
self.showAllChats();
}, 1500);
}
});
Комментарии (0) RSS
Добавить комментарий