comparison 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
comparison
equal deleted inserted replaced
134:ee7b4aecdc67 135:ceef355156de
97 item_type = None 97 item_type = None
98 DOM.eventPreventDefault(event) 98 DOM.eventPreventDefault(event)
99 if item_type=="GROUP": 99 if item_type=="GROUP":
100 _new_panel = MicroblogPanel(self.host, [item]) 100 _new_panel = MicroblogPanel(self.host, [item])
101 _new_panel.setAcceptedGroup(item) 101 _new_panel.setAcceptedGroup(item)
102 self.host.FillMicroblogPanel(_new_panel) #XXX: cache is temporarly deactivated, need to be reworked 102 #self.host.FillMicroblogPanel(_new_panel) #XXX: cache is temporarly deactivated, need to be reworked
103 self.host.bridge.call('getMassiveLastMblogs', _new_panel.massiveInsert, 'GROUP', [item], 10)
103 elif item_type=="CONTACT": 104 elif item_type=="CONTACT":
104 _contact = JID(item) 105 _contact = JID(item)
105 self.host.contact_panel.setContactMessageWaiting(_contact.bare, False) 106 self.host.contact_panel.setContactMessageWaiting(_contact.bare, False)
106 _new_panel = ChatPanel(self.host, _contact) 107 _new_panel = ChatPanel(self.host, _contact)
107 _new_panel.historyPrint() 108 _new_panel.historyPrint()
487 488
488 def __init__(self, host, mblog_entry): 489 def __init__(self, host, mblog_entry):
489 SimplePanel.__init__(self) 490 SimplePanel.__init__(self)
490 491
491 self.author = mblog_entry.author 492 self.author = mblog_entry.author
493 self.timestamp = mblog_entry.timestamp
492 _datetime = datetime.fromtimestamp(mblog_entry.timestamp) 494 _datetime = datetime.fromtimestamp(mblog_entry.timestamp)
493 495
494 self.panel = HTMLPanel(""" 496 self.panel = HTMLPanel("""
495 <div class='mb_entry_header'><span class='mb_entry_author'>%(author)s</span> on <span class='mb_entry_timestamp'>%(timestamp)s</span></div> 497 <div class='mb_entry_header'><span class='mb_entry_author'>%(author)s</span> on <span class='mb_entry_timestamp'>%(timestamp)s</span></div>
496 <div class="mb_entry_avatar" id='id_avatar'></div> 498 <div class="mb_entry_avatar" id='id_avatar'></div>
554 """ 556 """
555 if mblog_entry.id in self.entries: 557 if mblog_entry.id in self.entries:
556 return 558 return
557 _entry = MicroblogEntry(self.host, mblog_entry) 559 _entry = MicroblogEntry(self.host, mblog_entry)
558 self.entries[mblog_entry.id] = _entry 560 self.entries[mblog_entry.id] = _entry
559 self.vpanel.insert(_entry,0) 561
562 # we look for the right index to insert our entry:
563 # we insert the entry above the first entry
564 # in the past
565 idx = 0
566 for child in self.vpanel.children:
567 if not isinstance(child, MicroblogEntry):
568 break
569 if child.timestamp < mblog_entry.timestamp:
570 break
571 idx+=1
572 self.vpanel.insert(_entry,idx)
560 573
561 def updateValue(self, type, jid, value): 574 def updateValue(self, type, jid, value):
562 """Update a jid value in entries 575 """Update a jid value in entries
563 @param type: one of 'avatar', 'nick' 576 @param type: one of 'avatar', 'nick'
564 @param jid: jid concerned 577 @param jid: jid concerned