comparison 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
comparison
equal deleted inserted replaced
513:8ee9113d307b 514:fe79a724e6fa
239 assert isinstance(from_jid, JID) 239 assert isinstance(from_jid, JID)
240 try: 240 try:
241 jid,nick,mymess = QuickChat.printMessage(self, from_jid, msg, profile, timestamp) 241 jid,nick,mymess = QuickChat.printMessage(self, from_jid, msg, profile, timestamp)
242 except TypeError: 242 except TypeError:
243 return 243 return
244 if timestamp:
245 for _chat_text in self.content:
246 if (msg == _chat_text.message and
247 timestamp - time.mktime(_chat_text.timestamp) < 5):
248 #we discard double messages, to avoid backlog / history conflict
249 return
244 my_jid = self.host.profiles[profile]['whoami'] 250 my_jid = self.host.profiles[profile]['whoami']
245 self.content.append(ChatText(self, timestamp or None, nick, mymess, msg)) 251 self.content.append(ChatText(self, timestamp or None, nick, mymess, msg))
246 if self.text_list.get_focus()[1] == len(self.content)-2: 252 if self.text_list.get_focus()[1] == len(self.content)-2:
247 #we don't change focus if user is not at the bottom 253 #we don't change focus if user is not at the bottom
248 #as that mean that he is probably watching discussion history 254 #as that mean that he is probably watching discussion history