diff 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
line wrap: on
line diff
--- a/frontends/src/primitivus/chat.py	Sat Aug 23 20:26:04 2014 +0200
+++ b/frontends/src/primitivus/chat.py	Sun Aug 24 18:39:32 2014 +0200
@@ -297,7 +297,8 @@
         if timestamp and self.content:
             for idx in range(len(self.content) - 1, -1, -1):
                 current_text = self.content[idx]
-                if new_text.timestamp < current_text.timestamp and idx > 0:
+                older = new_text.timestamp < current_text.timestamp
+                if older and idx > 0:
                     continue  # the new message is older, we need to insert it upper
 
                 #we discard double messages, to avoid backlog / history conflict
@@ -306,7 +307,7 @@
                     (idx < len(self.content) - 2 and self.content[idx + 1].message)):
                     return
 
-                self.content.insert(idx + 1, new_text)
+                self.content.insert(0 if older else idx + 1, new_text)
                 break
         else:
             self.content.append(new_text)