diff src/browser/sat_browser/blog.py @ 624:9092e624bb27 frontends_multi_profiles

browser_side: fixes various issues
author souliane <souliane@mailoo.org>
date Sun, 22 Feb 2015 21:51:20 +0100
parents 2c41ce0c3b3f
children 63697f082e8a
line wrap: on
line diff
--- a/src/browser/sat_browser/blog.py	Sun Feb 22 21:42:14 2015 +0100
+++ b/src/browser/sat_browser/blog.py	Sun Feb 22 21:51:20 2015 +0100
@@ -166,7 +166,7 @@
         is_publisher = self.author == self._blog_panel.host.whoami.bare
         if is_publisher:
             self.update_label = addIcon(u"✍", "Edit this message")
-        if is_publisher or str(self.node).endswith(self._blog_panel.host.whoami.bare):
+        if is_publisher or str(self.node).endswith(unicode(self._blog_panel.host.whoami.bare)):
             self.delete_label = addIcon(u"✗", "Delete this message")
 
     def updateAvatar(self, new_avatar):
@@ -374,7 +374,10 @@
         self.vpanel = VerticalPanel()
         self.vpanel.setStyleName('microblogPanel')
         self.setWidget(self.vpanel)
-        host.addListener('avatar', self.onAvatarUpdate)
+
+        # FIXME: workaround for a pyjamas issue: calling hash on a class method always return a different value if that method is defined directly within the class (with the "def" keyword)
+        self.avatarListener = self.onAvatarUpdate
+        host.addListener('avatar', self.avatarListener, [C.PROF_KEY_NONE])
 
     def __str__(self):
         return u"Blog Widget [target: {}, profile: {}]".format(self.target, self.profile)
@@ -385,17 +388,16 @@
 
     def onDelete(self):
         quick_widgets.QuickWidget.onDelete(self)
-        self.host.removeListener('avatar', self.onAvatarUpdate)
+        self.host.removeListener('avatar', self.avatarListener)
 
-    def onAvatarUpdate(self, jid_, hash_, profile):
+    def onAvatarUpdate(self, jid_, hash_):
         """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
         """
-        whoami = self.host.profiles[self.profile].whoami.bare
-        if self.isJidAccepted(jid_) or jid_.bare  == whoami.bare:
+        whoami = self.host.profiles[self.profile].whoami
+        if self.isJidAccepted(jid_) or jid_.bare == whoami.bare:
             self.updateValue('avatar', jid_, hash_)
 
     def refresh(self):
@@ -567,7 +569,7 @@
         assert isinstance(sender, jid.JID) # FIXME temporary
         if (mblog_entry.type == "comment"
             or self.isJidAccepted(sender)
-            or (groups == None and sender == self.host.profiles[self.profile].whoami.bare)
+            or (groups is None and sender == self.host.profiles[self.profile].whoami.bare)
             or (groups and groups.intersection(self.accepted_groups))):
             self.addEntry(mblog_entry)
 
@@ -580,7 +582,7 @@
         _entry = MicroblogEntry(self, data)
         if _entry.type == "comment":
             comments_hash = (_entry.service, _entry.node)
-            if not comments_hash in self.comments:
+            if comments_hash not in self.comments:
                 # The comments node is not known in this panel
                 return None
             parent = self.comments[comments_hash]