diff browser_side/panels.py @ 135:ceef355156de

server + browser side: groupblog subscription + fixed blog insertion order
author Goffi <goffi@goffi.org>
date Mon, 25 Jun 2012 01:03:50 +0200
parents 30d8e328559b
children b145da69a218
line wrap: on
line diff
--- a/browser_side/panels.py	Thu Apr 05 09:28:48 2012 +0200
+++ b/browser_side/panels.py	Mon Jun 25 01:03:50 2012 +0200
@@ -99,7 +99,8 @@
         if item_type=="GROUP":
             _new_panel = MicroblogPanel(self.host, [item])
             _new_panel.setAcceptedGroup(item)
-            self.host.FillMicroblogPanel(_new_panel) #XXX: cache is temporarly deactivated, need to be reworked
+            #self.host.FillMicroblogPanel(_new_panel) #XXX: cache is temporarly deactivated, need to be reworked
+            self.host.bridge.call('getMassiveLastMblogs', _new_panel.massiveInsert, 'GROUP', [item], 10)
         elif item_type=="CONTACT":
             _contact = JID(item)
             self.host.contact_panel.setContactMessageWaiting(_contact.bare, False)
@@ -489,6 +490,7 @@
         SimplePanel.__init__(self)
 
         self.author = mblog_entry.author
+        self.timestamp = mblog_entry.timestamp
         _datetime = datetime.fromtimestamp(mblog_entry.timestamp)
 
         self.panel = HTMLPanel("""
@@ -556,7 +558,18 @@
             return
         _entry = MicroblogEntry(self.host, mblog_entry)
         self.entries[mblog_entry.id] = _entry
-        self.vpanel.insert(_entry,0)
+        
+        # we look for the right index to insert our entry:
+        # we insert the entry above the first entry
+        # in the past
+        idx = 0
+        for child in self.vpanel.children:
+            if not isinstance(child, MicroblogEntry):
+                break
+            if child.timestamp < mblog_entry.timestamp:
+                break
+            idx+=1
+        self.vpanel.insert(_entry,idx)
 
     def updateValue(self, type, jid, value):
         """Update a jid value in entries