diff src/browser/sat_browser/contact_list.py @ 607:537649f6a2d0 frontends_multi_profiles

browser side (blog, contact list): use of new listener mechanism to update avatar
author Goffi <goffi@goffi.org>
date Mon, 09 Feb 2015 21:56:30 +0100
parents 7af8f4ab3675
children ea27925ef2a8
line wrap: on
line diff
--- a/src/browser/sat_browser/contact_list.py	Mon Feb 09 21:55:16 2015 +0100
+++ b/src/browser/sat_browser/contact_list.py	Mon Feb 09 21:56:30 2015 +0100
@@ -335,11 +335,16 @@
         self.add(self.scroll_panel)
         self.setStyleName('contactList')
         Window.addWindowResizeListener(self)
+        host.addListerner('avatar', self.onAvatarUpdate)
 
     @property
     def profile(self):
         return C.PROF_KEY_NONE
 
+    def onDelete(self):
+        QuickContactList.onDelete(self)
+        self.host.removeListener('avatar', self.onAvatarUpdate)
+
     def update(self):
         ### GROUPS ###
         _keys = self._groups.keys()
@@ -535,6 +540,15 @@
         """
         self._contacts_panel.updateAvatar(jid_s, url)
 
+    def onAvatarUpdate(self, jid_, hash_, profile):
+        """Called on avatar update events
+
+        @param jid_: jid of the entity with updated avatar
+        @param hash_: hash of the avatar
+        @param profile: should be C.PROF_KEY_NONE
+        """
+        self._contacts_panel.updateAvatar(jid_, self.host.getAvatarURL(jid_))
+
     def hasVisibleMembers(self, group):
         """Tell if the given group actually has visible members