def _on_updates(self, data, hash=None): self.last_update_hash = hash removed = removed_ds.data() for pdata in data: post = pdata.get('obj', None) if post: key = post.get('key', None) if key and key not in removed: self.container.enqueue(key, post)
def _on_page(self, data, add_bottom=True, **kwargs): if not data: self.loading = False return # only insert when getting next page -- i.e. adding from the bottom systempost = self._on_page_add_system_post() if add_bottom else None removed = removed_ds.data() systempost_place = 0 for pdata in data: systempost_place += 1 if systempost and systempost_place == 4: self._add_system_post( key='system_post_%s' % (self.sys_posts_count + 1), index=0, **systempost) post = pdata.get('post', None) hash = pdata.get('hash', None) if post: key = post.get('key', None) if key in removed: continue d = convert_json_from_unicode(post) d['hash'] = hash if not key: continue if self.stream_system and self.stream_system.key in d['channels']: print 'Got system post' self.stream_system.hash_bounds = hash if len(d['content']) > 2 and d['content'][0] == '#': print 'Systempost -- deep link' key = d['content'][1:] def on_get_deeplink(data, hash): print 'Got deep links data' if len(data) > 0: wrapper = {'hash': hash, 'post': data[0]} self._on_page([wrapper], add_bottom=False) from api.items import get as getPostData getPostData(keys=[key], on_items=on_get_deeplink) continue d['background'] = 'bkg.jpg' d['when'] = 'once' if d['role_text'].lower() == 'invite': d['action'] = 'invite' d['button'] = 'send invitation' elif d['role_text'].lower() == 'linkedin': d['action'] = 'linkedin' d['button'] = 'Login with linkedin' else: d['action'] = 'close' d['key'] = 'system_post_%s' % (self.sys_posts_count + 1) d['index'] = -1 self._add_system_post(**d) continue if add_bottom: self.container.enqueue(key, d, index=0) else: self.container.enqueue(key, d, index=-1) self.loading = False
def _on_page(self, data, add_bottom=True, **kwargs): if not data: self.loading = False return # only insert when getting next page -- i.e. adding from the bottom systempost = self._on_page_add_system_post() if add_bottom else None removed = removed_ds.data() systempost_place = 0 for pdata in data: systempost_place += 1 if systempost and systempost_place == 4: self._add_system_post(key='system_post_%s' % (self.sys_posts_count + 1), index=0, **systempost) post = pdata.get('post', None) hash = pdata.get('hash', None) if post: key = post.get('key', None) if key in removed: continue d = convert_json_from_unicode(post) d['hash'] = hash if not key: continue if self.stream_system and self.stream_system.key in d[ 'channels']: print 'Got system post' self.stream_system.hash_bounds = hash if len(d['content']) > 2 and d['content'][0] == '#': print 'Systempost -- deep link' key = d['content'][1:] def on_get_deeplink(data, hash): print 'Got deep links data' if len(data) > 0: wrapper = {'hash': hash, 'post': data[0]} self._on_page([wrapper], add_bottom=False) from api.items import get as getPostData getPostData(keys=[key], on_items=on_get_deeplink) continue d['background'] = 'bkg.jpg' d['when'] = 'once' if d['role_text'].lower() == 'invite': d['action'] = 'invite' d['button'] = 'send invitation' elif d['role_text'].lower() == 'linkedin': d['action'] = 'linkedin' d['button'] = 'Login with linkedin' else: d['action'] = 'close' d['key'] = 'system_post_%s' % (self.sys_posts_count + 1) d['index'] = -1 self._add_system_post(**d) continue if add_bottom: self.container.enqueue(key, d, index=0) else: self.container.enqueue(key, d, index=-1) self.loading = False