... | ... |
@@ -90,9 +90,10 @@ this.App = |
90 | 90 |
@trigger(event: 'app.chat.kickFromMultichat', data: {chatId: chatId, me: me, kick: jidToKick}) |
91 | 91 |
|
92 | 92 |
syncMultiChatContacts: (me, chatId) -> |
93 |
- @trigger(event: 'app.chat.syncMultiChatContacts', data: {me: me, chatId: chatId}, success: (contacts) => |
|
94 |
- App.debug contacts |
|
95 |
- ) |
|
93 |
+ @trigger(event: 'app.chat.syncMultiChatContacts', data: {me: me, chatId: chatId}) |
|
94 |
+ |
|
95 |
+ syncedContacts: () -> |
|
96 |
+ |
|
96 | 97 |
|
97 | 98 |
updateMyStatus: (message, state)-> |
98 | 99 |
App.Com.trigger(event: 'app.roster.updateMyStatus', data: {message: message, state: state}) |
... | ... |
@@ -153,6 +154,15 @@ this.App = |
153 | 153 |
Backbone.Events.trigger('openChat', chat) |
154 | 154 |
) |
155 | 155 |
|
156 |
+ App._dispatcher.bind('app.chat.updateSyncedContacts', (syncData) -> |
|
157 |
+ App.debug ['new multichat contacts arrived', syncData.contacts] |
|
158 |
+ |
|
159 |
+ chat = App.Collections.chats.findById(syncData.chat_id) |
|
160 |
+ if chat |
|
161 |
+ chat.syncContacts(syncData.contacts, syncData.owner) |
|
162 |
+ Backbone.Events.trigger('openChat', chat) |
|
163 |
+ ) |
|
164 |
+ |
|
156 | 165 |
App._dispatcher.bind('app.chat.messageReceived', (result) -> |
157 | 166 |
App.debug ['message received', result] |
158 | 167 |
|
... | ... |
@@ -42,13 +42,13 @@ class Xmpp.Models.Chat extends Xmpp.Models.Model |
42 | 42 |
jid != App.Models.me.get('jid') |
43 | 43 |
) |
44 | 44 |
|
45 |
- if (owner != App.Models.me.get('jid')) |
|
46 |
- contactsWithoutMe = contactsWithoutMe.concat([owner]); |
|
45 |
+ if owner and owner != App.Models.me.get('jid') |
|
46 |
+ contactsWithoutMe = contactsWithoutMe.concat([owner]) |
|
47 | 47 |
|
48 | 48 |
attendants = _.map(contactsWithoutMe, (jid) => |
49 | 49 |
contact = App.Collections.contacts.findByJid(jid) |
50 | 50 |
if not contact |
51 |
- newTempContact = @createTempContact(jid) |
|
51 |
+ newTempContact = Xmpp.Collections.ChatsCollection.createTempContact(jid) |
|
52 | 52 |
App.Collections.contacts.add(newTempContact) |
53 | 53 |
contact = newTempContact |
54 | 54 |
|
... | ... |
@@ -60,7 +60,7 @@ class Xmpp.Models.Chat extends Xmpp.Models.Model |
60 | 60 |
if owner |
61 | 61 |
ownerContact = App.Collections.contacts.findByJid(owner) |
62 | 62 |
if not ownerContact |
63 |
- ownerContact = @createTempContact(owner) |
|
63 |
+ ownerContact = Xmpp.Collections.ChatsCollection.createTempContact(owner) |
|
64 | 64 |
App.Collections.contacts.add(ownerContact) |
65 | 65 |
|
66 | 66 |
@set('who', ownerContact) |
... | ... |
@@ -110,7 +110,7 @@ class WsChatController < WsController |
110 | 110 |
end |
111 | 111 |
end |
112 | 112 |
|
113 |
- def sync_chat_contacts |
|
113 |
+ def request_sync_chat_contacts |
|
114 | 114 |
client = find_client(message[:me]) |
115 | 115 |
chat_id = message[:chatId] |
116 | 116 |
|
... | ... |
@@ -179,11 +179,12 @@ class WsChatController < WsController |
179 | 179 |
end |
180 | 180 |
|
181 | 181 |
def sync_contacts_frontend(message, chat_id) |
182 |
- contacts = xml_contacts_to_array(message.first_element('sync_contacts')) |
|
182 |
+ contacts = xml_contacts_to_array(message.first_element('synced_contacts')) |
|
183 | 183 |
|
184 | 184 |
send_message 'app.chat.updateSyncedContacts', |
185 | 185 |
me: message.to.strip.to_s, |
186 | 186 |
contacts: contacts, |
187 |
+ owner: message.from.strip.to_s, |
|
187 | 188 |
chat_id: chat_id |
188 | 189 |
end |
189 | 190 |
|
... | ... |
@@ -217,6 +218,8 @@ class WsChatController < WsController |
217 | 217 |
contacts.each do |contact| |
218 | 218 |
client.send(MessageBuilder::send_multichat_contacts(client.jid.strip.to_s, contact, chat_id, contacts)) |
219 | 219 |
end |
220 |
+ |
|
221 |
+ sync_contacts_frontend(MessageBuilder::send_multichat_contacts('', client.jid.strip.to_s, chat_id, contacts), chat_id) |
|
220 | 222 |
end |
221 | 223 |
end |
222 | 224 |
end |
223 | 225 |
\ No newline at end of file |
... | ... |
@@ -65,7 +65,7 @@ WebsocketRails::EventMap.describe do |
65 | 65 |
subscribe :addToMultiChat, to: WsChatController, with_method: :add_to_multichat |
66 | 66 |
subscribe :sendMessage, to: WsChatController, with_method: :send_chat_message |
67 | 67 |
subscribe :startPollingMessages, to: WsChatController, with_method: :start_polling_messages |
68 |
- subscribe :syncMultiChatContacts, to: WsChatController, with_method: :sync_chat_contacts |
|
68 |
+ subscribe :syncMultiChatContacts, to: WsChatController, with_method: :request_sync_chat_contacts |
|
69 | 69 |
subscribe :iClosedMultichat, to: WsChatController, with_method: :i_closed_multichat |
70 | 70 |
subscribe :kickFromMultichat, to: WsChatController, with_method: :kick_from_multichat |
71 | 71 |
end |