Browse code

Zmazanie cloveka z rostera

Cinan Rakosnik authored on 16/05/2013 at 19:29:34
Showing 2 changed files
... ...
@@ -10,6 +10,7 @@ class Xmpp.Views.Contacts.ContactView extends Backbone.View
10 10
     'click .kick': 'kickFromMultiChat'
11 11
     'click .multichat': 'newMultiChat'
12 12
     'click .make-owner': 'switchOwner'
13
+    'click .remove': 'removeContact'
13 14
     click: 'startChat'
14 15
     mouseover: 'showIcons'
15 16
     mouseleave: 'hideIcons'
... ...
@@ -96,6 +97,12 @@ class Xmpp.Views.Contacts.ContactView extends Backbone.View
96 96
 
97 97
     App.Com.switchMultiChatOwner(App.Models.me.get('jid'), @model.get('jid'), multichat.get('chatId'))
98 98
 
99
+  removeContact: (e) ->
100
+    e.stopPropagation()
101
+    App.debug 'remove from roster'
102
+    App.Com.removeContactRemote(@model.get('jid'))
103
+    Backbone.Events.trigger('removeContact', @model)
104
+
99 105
   openChatById: (chatId) ->
100 106
     App.Collections.chats.findById(chatId)
101 107
 
... ...
@@ -122,16 +122,24 @@ class WsRosterController < WsController
122 122
         jid = message[:jid]
123 123
         client_jid = message[:client]
124 124
 
125
-        found_roster_item = nil
125
+        found_roster_items = []
126 126
         connection_store[:rosters].each do |roster|
127 127
             roster_item = roster.find(jid)
128
-            if roster_item.first[1] && connection_store[:link_roster_client][roster].jid.strip.to_s == client_jid
129
-                found_roster_item = roster_item.first[1]
130
-                break
128
+            contact_obj = roster_item.first[1]
129
+
130
+            if contact_obj
131
+                if client_jid && connection_store[:link_roster_client][roster].jid.strip.to_s == client_jid
132
+                    found_roster_items = [ contact_obj ]
133
+                    break
134
+                else
135
+                    found_roster_items.push(contact_obj)
136
+                end
131 137
             end
132 138
         end
133 139
 
134
-        found_roster_item && found_roster_item.remove()
140
+        found_roster_items.each do |contact|
141
+            contact.remove()
142
+        end
135 143
     end
136 144
 
137 145
     ##