diff src/browser/sat_browser/panels.py @ 584:0a06cf833f5a

browser_side: various improvements, especially for MUC
author souliane <souliane@mailoo.org>
date Wed, 22 Oct 2014 19:03:55 +0200
parents 1c1dbe03d3c6
children bade589dbd5a
line wrap: on
line diff
--- a/src/browser/sat_browser/panels.py	Wed Oct 22 14:19:25 2014 +0200
+++ b/src/browser/sat_browser/panels.py	Wed Oct 22 19:03:55 2014 +0200
@@ -1133,6 +1133,7 @@
         chat_area.setStyleName('chatArea')
         if type_ == 'group':
             self.occupants_list = base_panels.OccupantsList()
+            self.occupants_initialised = False
             chat_area.add(self.occupants_list)
         self.__body.add(chat_area)
         self.content = AbsolutePanel()
@@ -1157,7 +1158,8 @@
         _contact = item if isinstance(item, jid.JID) else jid.JID(item)
         host.contact_panel.setContactMessageWaiting(_contact.bare, False)
         _new_panel = ChatPanel(host, _contact, type_)  # XXX: pyjamas doesn't seems to support creating with cls directly
-        _new_panel.historyPrint()
+        if type == 'one2one':
+            _new_panel.historyPrint()
         host.setSelected(_new_panel)
         _new_panel.refresh()
         return _new_panel
@@ -1187,7 +1189,6 @@
     def matchEntity(self, item, type_=None):
         """
         @param entity: target jid as a string or jid.JID instance.
-        Could also be a couple with a type in the second element.
         @return: True if self matches the given entity
         """
         if type_ is None:
@@ -1234,13 +1235,16 @@
     def setPresents(self, nicks):
         """Set the users presents in this room
         @param occupants: list of nicks (string)"""
-        self.occupants_list.clear()
         for nick in nicks:
             self.occupants_list.addOccupant(nick)
+        self.occupants_initialised = True
 
     def userJoined(self, nick, data):
+        if self.occupants_list.getOccupantBox(nick):
+            return  # user is already displayed
         self.occupants_list.addOccupant(nick)
-        self.printInfo("=> %s has joined the room" % nick)
+        if self.occupants_initialised:
+            self.printInfo("=> %s has joined the room" % nick)
 
     def userLeft(self, nick, data):
         self.occupants_list.removeOccupant(nick)
@@ -1333,7 +1337,7 @@
         to set the state for a one2one conversation, or give a nickname or
         C.ALL_OCCUPANTS to set the state of a participant within a MUC.
         @param state: the new chat state
-        @param nick: None for one2one, the MUC user nick or ALL_OCCUPANTS
+        @param nick: ignored for one2one, otherwise the MUC user nick or C.ALL_OCCUPANTS
         """
         if self.type == 'group':
             assert(nick)