comparison libervia.py @ 205:ee744ffed7fc

browser side: events data are cached until initialisation is finished (we get all microblogs)
author Goffi <goffi@goffi.org>
date Thu, 20 Jun 2013 12:16:46 +0200
parents 890776a6fdb7
children 3092f6b1710c
comparison
equal deleted inserted replaced
204:890776a6fdb7 205:ee744ffed7fc
162 RootPanel().add(self.panel) 162 RootPanel().add(self.panel)
163 DOM.addEventPreview(self) 163 DOM.addEventPreview(self)
164 self.resize() 164 self.resize()
165 self._register = RegisterCall() 165 self._register = RegisterCall()
166 self._register.call('isRegistered',self._isRegisteredCB) 166 self._register.call('isRegistered',self._isRegisteredCB)
167 self.initialised = False
168 self.init_cache = [] # used to cache events until initialisation is done
167 169
168 def addSelectedListener(self, callback): 170 def addSelectedListener(self, callback):
169 self._selected_listeners.add(callback) 171 self._selected_listeners.add(callback)
170 172
171 def getSelected(self): 173 def getSelected(self):
356 if len(self.mblog_cache) > MAX_MBLOG_CACHE: 358 if len(self.mblog_cache) > MAX_MBLOG_CACHE:
357 del self.mblog_cache[0:len(self.mblog_cache-MAX_MBLOG_CACHE)] 359 del self.mblog_cache[0:len(self.mblog_cache-MAX_MBLOG_CACHE)]
358 for lib_wid in self.libervia_widgets: 360 for lib_wid in self.libervia_widgets:
359 if isinstance(lib_wid, panels.MicroblogPanel): 361 if isinstance(lib_wid, panels.MicroblogPanel):
360 self.FillMicroblogPanel(lib_wid) 362 self.FillMicroblogPanel(lib_wid)
363 self.initialised = True # initialisation phase is finished here
364 for event_data in self.init_cache: # so we have to send all the cached events
365 self._personalEventCb(*event_data)
366 del self.init_cache
361 367
362 def _getProfileJidCB(self, jid): 368 def _getProfileJidCB(self, jid):
363 self.whoami = JID(jid) 369 self.whoami = JID(jid)
364 #we can now ask our status 370 #we can now ask our status
365 self.bridge.call('getPresenceStatus', self._getPresenceStatusCb) 371 self.bridge.call('getPresenceStatus', self._getPresenceStatusCb)
379 self.bridge.call('getMassiveLastMblogs', self._ownBlogsFills, 'JID', [self.whoami.bare], 10) 385 self.bridge.call('getMassiveLastMblogs', self._ownBlogsFills, 'JID', [self.whoami.bare], 10)
380 386
381 ## Signals callbacks ## 387 ## Signals callbacks ##
382 388
383 def _personalEventCb(self, sender, event_type, data): 389 def _personalEventCb(self, sender, event_type, data):
390 if not self.initialised:
391 self.init_cache.append((sender, event_type, data))
392 return
384 if event_type == "MICROBLOG": 393 if event_type == "MICROBLOG":
385 if not 'content' in data: 394 if not 'content' in data:
386 print ("WARNING: No content found in microblog data") 395 print ("WARNING: No content found in microblog data")
387 return 396 return
388 if 'groups' in data: 397 if 'groups' in data: