comparison frontends/src/primitivus/contact_list.py @ 2016:f09562b0704d

quick_frontend, primitivus: better notifications handling
author Goffi <goffi@goffi.org>
date Sun, 24 Jul 2016 17:56:14 +0200
parents 20fb71b656e3
children 7aa58b7a47e2
comparison
equal deleted inserted replaced
2015:20fb71b656e3 2016:f09562b0704d
141 entity = contact_wid.data 141 entity = contact_wid.data
142 self.host.modeHint(C.MODE_INSERTION) 142 self.host.modeHint(C.MODE_INSERTION)
143 self._emit('click', entity) 143 self._emit('click', entity)
144 144
145 def onNotification(self, entity, notif, profile): 145 def onNotification(self, entity, notif, profile):
146 notifs = self.host.getNotifs(C.ENTITY_ALL, profile=self.profile) 146 notifs = list(self.host.getNotifs(C.ENTITY_ALL, profile=self.profile))
147 if notifs: 147 if notifs:
148 self.title_dynamic = u"({})".format(len(notifs)) 148 self.title_dynamic = u"({})".format(len(notifs))
149 else: 149 else:
150 self.title_dynamic = None 150 self.title_dynamic = None
151 self.host.redraw() # FIXME: should not be necessary 151 self.host.redraw() # FIXME: should not be necessary
195 show_icon, entity_attr = C.PRESENCE.get(show, ('', 'default')) 195 show_icon, entity_attr = C.PRESENCE.get(show, ('', 'default'))
196 markup.insert(0, u"{} ".format(show_icon)) 196 markup.insert(0, u"{} ".format(show_icon))
197 else: 197 else:
198 entity_attr = 'default' 198 entity_attr = 'default'
199 199
200 notifs = self.host.getNotifs(entity.bare, profile=self.profile) 200 notifs = list(self.host.getNotifs(entity, exact_jid=special, profile=self.profile))
201 if notifs: 201 if notifs:
202 entity_attr = 'cl_notifs' 202 header = [('cl_notifs', u'({})'.format(len(notifs))), u' ']
203 header = u'({}) '.format(len(notifs)) 203 if list(self.host.getNotifs(entity.bare, C.NOTIFY_MENTION, profile=self.profile)):
204 if self.host.getNotifs(entity.bare, C.NOTIFY_MENTION, profile=self.profile):
205 header = ('cl_mention', header) 204 header = ('cl_mention', header)
206 else: 205 else:
207 header = u'' 206 header = u''
208 207
209 markup.append((entity_attr, entity_txt)) 208 markup.append((entity_attr, entity_txt))