comparison frontends/src/primitivus/chat.py @ 1751:77870d2e2902

primitivus (chat): duplicate message check is actually not needed when retrieving local MUC history is disabled
author souliane <souliane@mailoo.org>
date Wed, 16 Dec 2015 13:29:24 +0100
parents 3a6cd1c14974
children 2e2fb462729a
comparison
equal deleted inserted replaced
1750:6fd0881fe1fc 1751:77870d2e2902
304 @param my_message (boolean): True if profile is the author 304 @param my_message (boolean): True if profile is the author
305 @param message (unicode): message content 305 @param message (unicode): message content
306 @param extra (dict): extra data 306 @param extra (dict): extra data
307 """ 307 """
308 new_text = ChatText(self, timestamp, nick, my_message, message) 308 new_text = ChatText(self, timestamp, nick, my_message, message)
309 if timestamp and self.content: 309 self.content.append(new_text)
310 for idx in range(len(self.content) - 1, -1, -1):
311 current_text = self.content[idx]
312 older = new_text.timestamp < current_text.timestamp
313 if older and idx > 0:
314 continue # the new message is older, we need to insert it upper
315
316 # we discard double messages, to avoid backlog / history conflict
317 # FIXME: messages that have been sent several times will be displayed only once
318 if ((idx and self.content[idx - 1].message == message) or
319 (self.content[idx].message == message) or
320 (idx < len(self.content) - 2 and self.content[idx + 1].message)):
321 return
322
323 self.content.insert(0 if older else idx + 1, new_text)
324 break
325 else:
326 self.content.append(new_text)
327 if not timestamp: 310 if not timestamp:
328 # XXX: do not send notifications for each line of the history being displayed 311 # XXX: do not send notifications for each line of the history being displayed
329 # FIXME: this must be changed in the future if the timestamp is passed with 312 # FIXME: this must be changed in the future if the timestamp is passed with
330 # all messages and not only with the messages coming from the history. 313 # all messages and not only with the messages coming from the history.
331 self._notify(nick, message) 314 self._notify(nick, message)