diff frontends/src/primitivus/chat.py @ 514:fe79a724e6fa

Primitivus: avoid double messages in case of backlog/history conflict
author Goffi <goffi@goffi.org>
date Sat, 20 Oct 2012 17:24:30 +0200
parents 62f7f2403093
children 75216d94a89d
line wrap: on
line diff
--- a/frontends/src/primitivus/chat.py	Sat Oct 20 17:23:56 2012 +0200
+++ b/frontends/src/primitivus/chat.py	Sat Oct 20 17:24:30 2012 +0200
@@ -241,6 +241,12 @@
             jid,nick,mymess = QuickChat.printMessage(self, from_jid, msg, profile, timestamp)
         except TypeError:
             return
+        if timestamp:
+            for _chat_text in self.content:
+                if (msg == _chat_text.message and
+                    timestamp - time.mktime(_chat_text.timestamp) < 5):
+                    #we discard double messages, to avoid backlog / history conflict
+                    return
         my_jid = self.host.profiles[profile]['whoami']
         self.content.append(ChatText(self, timestamp or None, nick, mymess, msg))
         if self.text_list.get_focus()[1] == len(self.content)-2: