changeset 1764:33c815c17fe6

quick_frontend (chat): temporary fix for bug 12: - avoid duplicate one2one message (before the history + as a part of it) - do not display "=> <nick> has joined the room" for each occupant when we have just joined a MUC
author souliane <souliane@mailoo.org>
date Tue, 22 Dec 2015 11:44:51 +0100
parents 9b557e76a5a8
children b9493cb6ce49
files frontends/src/quick_frontend/quick_chat.py
diffstat 1 files changed, 13 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/frontends/src/quick_frontend/quick_chat.py	Tue Dec 22 11:43:02 2015 +0100
+++ b/frontends/src/quick_frontend/quick_chat.py	Tue Dec 22 11:44:51 2015 +0100
@@ -55,6 +55,9 @@
         if type_ == C.CHAT_ONE2ONE:
             self.historyPrint(profile=self.profile)
 
+        # FIXME: has been introduced to temporarily fix http://bugs.goffi.org/show_bug.cgi?id=12
+        self.initialised = False
+
     def __str__(self):
         return u"Chat Widget [target: {}, type: {}, profile: {}]".format(self.target, self.type, self.profile)
 
@@ -109,6 +112,8 @@
 
     def addUser(self, nick):
         """Add user if it is not in the group list"""
+        if not self.initialised:
+            return  # FIXME: tmp fix for bug 12, do not flood the room with the messages when we've just entered it
         self.printInfo("=> %s has joined the room" % nick)
 
     def removeUser(self, nick):
@@ -148,6 +153,7 @@
         target = self.target.bare
 
         def onHistory(history):
+            self.initialised = True  # FIXME: tmp fix for bug 12
             day_format = "%A, %d %b %Y"  # to display the day change
             previous_day = datetime.now().strftime(day_format)
             for line in history:
@@ -166,6 +172,7 @@
         def onHistoryError(err):
             log.error(_("Can't get history"))
 
+        self.initialised = False  # FIXME: tmp fix for bug 12, here needed for :history and :search commands
         self.host.bridge.getHistory(unicode(self.host.profiles[profile].whoami.bare), unicode(target), size, True, search, profile, callback=onHistory, errback=onHistoryError)
 
     def _get_nick(self, entity):
@@ -198,9 +205,15 @@
             timestamp = float(extra['timestamp'])
         except KeyError:
             timestamp = None
+
+        if not self.initialised and self.type == C.CHAT_ONE2ONE:
+            return  # FIXME: tmp fix for bug 12, do not display the first one2one message which is already in the local history
+
         if type_ == C.MESS_TYPE_INFO:
             self.printInfo(msg, extra=extra)
         else:
+            self.initialised = True  # FIXME: tmp fix for bug 12, do not discard any message from now
+
             nick = self._get_nick(from_jid)
             if msg.startswith('/me '):
                 self.printInfo('* %s %s' % (nick, msg[4:]), type_='me', extra=extra)