Mercurial > libervia-web
comparison src/browser/sat_browser/contact_list.py @ 687:3845a086f0b3
browser_side: update ContactList, Chat, ContactsPanel, ContactBox, ContactLabel to update the display using listeners as it is done in quick_frontend:
- Chat uses presence and avatar listener, remove unecessary methods for MUC and contact states
- contact list doesn't add unecessary ContactBox (e.g for MUC bare entities)
- nick, message alerts are handled directly in ContactLabel
author | souliane <souliane@mailoo.org> |
---|---|
date | Mon, 23 Mar 2015 09:35:46 +0100 |
parents | 9877607c719a |
children | 6fc3ff3936ba |
comparison
equal
deleted
inserted
replaced
686:90a5a5af2550 | 687:3845a086f0b3 |
---|---|
174 to_show = [jid_ for jid_ in self.roster_entities if self.entityToShow(jid_) and jid_ != self.whoami.bare] | 174 to_show = [jid_ for jid_ in self.roster_entities if self.entityToShow(jid_) and jid_ != self.whoami.bare] |
175 to_show.sort() | 175 to_show.sort() |
176 | 176 |
177 self._contacts_panel.setList(to_show) | 177 self._contacts_panel.setList(to_show) |
178 | 178 |
179 for jid_ in self._alerts: | |
180 self._contacts_panel.getContactBox(jid_).setAlert(True) | |
181 | |
182 def remove(self, entity): | 179 def remove(self, entity): |
183 # FIXME: SimplePanel and QuickContactList both have a 'remove' method | 180 # FIXME: SimplePanel and QuickContactList both have a 'remove' method |
184 QuickContactList.remove(self, entity) | 181 QuickContactList.remove(self, entity) |
185 | 182 |
186 def onWindowResized(self, width, height): | 183 def onWindowResized(self, width, height): |
337 | 334 |
338 @param jid_: jid of the entity with updated avatar | 335 @param jid_: jid of the entity with updated avatar |
339 @param hash_: hash of the avatar | 336 @param hash_: hash of the avatar |
340 @param profile: %(doc_profile)s | 337 @param profile: %(doc_profile)s |
341 """ | 338 """ |
342 self._contacts_panel.updateAvatar(jid_, self.host.getAvatarURL(jid_)) | 339 box = self._contacts_panel.getContactBox(jid_) |
340 if box: | |
341 box.update() | |
343 | 342 |
344 def onNickUpdate(self, jid_, new_nick, profile): | 343 def onNickUpdate(self, jid_, new_nick, profile): |
345 self._contacts_panel.updateNick(jid_, new_nick) | 344 box = self._contacts_panel.getContactBox(jid_) |
345 if box: | |
346 box.update() | |
346 | 347 |
347 def hasVisibleMembers(self, group): | 348 def hasVisibleMembers(self, group): |
348 """Tell if the given group actually has visible members | 349 """Tell if the given group actually has visible members |
349 | 350 |
350 @param group (unicode): the group to check | 351 @param group (unicode): the group to check |
351 @return: boolean | 352 @return: boolean |
352 """ | 353 """ |
353 raise Exception # FIXME: remove this method | 354 raise Exception # FIXME: remove this method |
354 for jid_ in self.groups[group]: | 355 for jid_ in self.groups[group]: |
355 if self._contacts_panel.getContactBox(jid_).isVisible(): | 356 if self._contacts_panel.updateContactBox(jid_).isVisible(): |
356 return True | 357 return True |
357 return False | 358 return False |
358 | 359 |
359 def offlineContactsToShow(self): | 360 def offlineContactsToShow(self): |
360 """Tell if offline contacts should be visible according to the user settings | 361 """Tell if offline contacts should be visible according to the user settings |
370 """ | 371 """ |
371 return C.bool(self.host.getCachedParam('General', C.SHOW_EMPTY_GROUPS)) | 372 return C.bool(self.host.getCachedParam('General', C.SHOW_EMPTY_GROUPS)) |
372 | 373 |
373 def onPresenceUpdate(self, entity, show, priority, statuses, profile): | 374 def onPresenceUpdate(self, entity, show, priority, statuses, profile): |
374 QuickContactList.onPresenceUpdate(self, entity, show, priority, statuses, profile) | 375 QuickContactList.onPresenceUpdate(self, entity, show, priority, statuses, profile) |
375 self._contacts_panel.setPresence(entity, show) | 376 box = self._contacts_panel.getContactBox(entity) |
377 if box: # box doesn't exist for MUC bare entity, don't create it | |
378 box.update() | |
376 | 379 |
377 # def updateVisibility(self, jids, groups): | 380 # def updateVisibility(self, jids, groups): |
378 # """Set the widgets visibility for the given contacts and groups | 381 # """Set the widgets visibility for the given contacts and groups |
379 | 382 |
380 # @param jids (list[unicode]): list of JID | 383 # @param jids (list[unicode]): list of JID |