Mercurial > libervia-backend
comparison frontends/src/primitivus/chat.py @ 1126:8870417c8e8c
primitivus (chat): fixes the messages display when opening a new chat window
author | souliane <souliane@mailoo.org> |
---|---|
date | Sun, 24 Aug 2014 18:39:32 +0200 |
parents | d6c3fea5ecfe |
children | 7e6856902488 |
comparison
equal
deleted
inserted
replaced
1125:d6c3fea5ecfe | 1126:8870417c8e8c |
---|---|
295 new_text = ChatText(self, timestamp or None, nick, mymess, msg) | 295 new_text = ChatText(self, timestamp or None, nick, mymess, msg) |
296 | 296 |
297 if timestamp and self.content: | 297 if timestamp and self.content: |
298 for idx in range(len(self.content) - 1, -1, -1): | 298 for idx in range(len(self.content) - 1, -1, -1): |
299 current_text = self.content[idx] | 299 current_text = self.content[idx] |
300 if new_text.timestamp < current_text.timestamp and idx > 0: | 300 older = new_text.timestamp < current_text.timestamp |
301 if older and idx > 0: | |
301 continue # the new message is older, we need to insert it upper | 302 continue # the new message is older, we need to insert it upper |
302 | 303 |
303 #we discard double messages, to avoid backlog / history conflict | 304 #we discard double messages, to avoid backlog / history conflict |
304 if ((idx and self.content[idx - 1].message == msg) or | 305 if ((idx and self.content[idx - 1].message == msg) or |
305 (self.content[idx].message == msg) or | 306 (self.content[idx].message == msg) or |
306 (idx < len(self.content) - 2 and self.content[idx + 1].message)): | 307 (idx < len(self.content) - 2 and self.content[idx + 1].message)): |
307 return | 308 return |
308 | 309 |
309 self.content.insert(idx + 1, new_text) | 310 self.content.insert(0 if older else idx + 1, new_text) |
310 break | 311 break |
311 else: | 312 else: |
312 self.content.append(new_text) | 313 self.content.append(new_text) |
313 if not timestamp: | 314 if not timestamp: |
314 # XXX: do not send notifications for each line of the history being displayed | 315 # XXX: do not send notifications for each line of the history being displayed |