Mercurial > libervia-backend
comparison sat_frontends/primitivus/chat.py @ 2988:b5f8cb26ef6f
quick frontend (chat), primitivus(chat): properly clear occupants on resync:
occupants widgets were not cleared in Primitivus on resync while occupants dictionary was, resulting in nicknames sometimes apearing doubled in Primitivus MUC rooms.
A new occupantsClear method has been added in QuickChat, so it can be overriden by frontends to clear widgets or other representations of occupants.
fix 304
author | Goffi <goffi@goffi.org> |
---|---|
date | Sat, 06 Jul 2019 12:22:25 +0200 |
parents | 5bba8953061e |
children | 4d5b9d4c7448 |
comparison
equal
deleted
inserted
replaced
2987:8990ed9aad31 | 2988:b5f8cb26ef6f |
---|---|
242 super(OccupantsWidget, self).__init__(occupants_widget) | 242 super(OccupantsWidget, self).__init__(occupants_widget) |
243 occupants_list = sorted(self.parent.occupants.keys(), key=lambda o: o.lower()) | 243 occupants_list = sorted(self.parent.occupants.keys(), key=lambda o: o.lower()) |
244 for occupant in occupants_list: | 244 for occupant in occupants_list: |
245 occupant_data = self.parent.occupants[occupant] | 245 occupant_data = self.parent.occupants[occupant] |
246 self.occupants_walker.append(OccupantWidget(occupant_data)) | 246 self.occupants_walker.append(OccupantWidget(occupant_data)) |
247 | |
248 def clear(self): | |
249 del self.occupants_walker[:] | |
247 | 250 |
248 def updateFooter(self): | 251 def updateFooter(self): |
249 """update footer widget""" | 252 """update footer widget""" |
250 txt = OCCUPANTS_FOOTER.format(len(self.parent.occupants)) | 253 txt = OCCUPANTS_FOOTER.format(len(self.parent.occupants)) |
251 self.occupants_footer.set_text(txt) | 254 self.occupants_footer.set_text(txt) |
496 def removeUser(self, occupant_data): | 499 def removeUser(self, occupant_data): |
497 occupant = super(Chat, self).removeUser(occupant_data) | 500 occupant = super(Chat, self).removeUser(occupant_data) |
498 if occupant is not None: | 501 if occupant is not None: |
499 self.occupants_widget.removeUser(occupant) | 502 self.occupants_widget.removeUser(occupant) |
500 | 503 |
504 def occupantsClear(self): | |
505 super(Chat, self).occupantsClear() | |
506 self.occupants_widget.clear() | |
507 | |
501 def _occupantsClicked(self, occupant, clicked_wid): | 508 def _occupantsClicked(self, occupant, clicked_wid): |
502 assert self.type == C.CHAT_GROUP | 509 assert self.type == C.CHAT_GROUP |
503 contact_list = self.host.contact_lists[self.profile] | 510 contact_list = self.host.contact_lists[self.profile] |
504 | 511 |
505 # we have a click on a nick, we need to create the widget if it doesn't exists | 512 # we have a click on a nick, we need to create the widget if it doesn't exists |