changeset 463:b62c1cf0dbf7

browser side: a new message being edited should always stay on top position (or last position for a comment)
author souliane <souliane@mailoo.org>
date Wed, 04 Jun 2014 01:27:11 +0200
parents 07433bd892ee
children bea9788f3170
files src/browser/panels.py
diffstat 1 files changed, 4 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/src/browser/panels.py	Wed Jun 04 00:23:14 2014 +0200
+++ b/src/browser/panels.py	Wed Jun 04 01:27:11 2014 +0200
@@ -834,6 +834,7 @@
         @param vpanel: VerticalPanel instance
         @param entry: MicroblogEntry
         @param reverse: more recent entry on top if True, chronological order else"""
+        assert(isinstance(reverse, bool))
         if entry.empty:
             entry.published = time()
         # we look for the right index to insert our entry:
@@ -845,12 +846,9 @@
             if not isinstance(child, MicroblogEntry):
                 idx += 1
                 continue
-            if reverse:
-                if child.published < entry.published:
-                    break
-            else:
-                if child.published > entry.published:
-                    break
+            condition_to_stop = child.empty or (child.published > entry.published)
+            if condition_to_stop != reverse:  # != is XOR
+                break
             idx += 1
 
         vpanel.insert(entry, idx)