From 31a9e2bd097634800c5ed93a4813ffa8d4ba6c6a Mon Sep 17 00:00:00 2001 From: Goffi Date: Sat, 6 Jul 2019 12:22:25 +0200 Subject: [PATCH] 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 --- sat_frontends/primitivus/chat.py | 7 +++++++ sat_frontends/quick_frontend/quick_chat.py | 9 ++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/sat_frontends/primitivus/chat.py b/sat_frontends/primitivus/chat.py index 110e6d73..d2cdcec5 100644 --- a/sat_frontends/primitivus/chat.py +++ b/sat_frontends/primitivus/chat.py @@ -245,6 +245,9 @@ class OccupantsWidget(urwid.WidgetWrap): occupant_data = self.parent.occupants[occupant] self.occupants_walker.append(OccupantWidget(occupant_data)) + def clear(self): + del self.occupants_walker[:] + def updateFooter(self): """update footer widget""" txt = OCCUPANTS_FOOTER.format(len(self.parent.occupants)) @@ -498,6 +501,10 @@ class Chat(PrimitivusWidget, quick_chat.QuickChat): if occupant is not None: self.occupants_widget.removeUser(occupant) + def occupantsClear(self): + super(Chat, self).occupantsClear() + self.occupants_widget.clear() + def _occupantsClicked(self, occupant, clicked_wid): assert self.type == C.CHAT_GROUP contact_list = self.host.contact_lists[self.profile] diff --git a/sat_frontends/quick_frontend/quick_chat.py b/sat_frontends/quick_frontend/quick_chat.py index 79aec100..6f8f8732 100644 --- a/sat_frontends/quick_frontend/quick_chat.py +++ b/sat_frontends/quick_frontend/quick_chat.py @@ -393,6 +393,13 @@ class QuickChat(quick_widgets.QuickWidget): self.sync = True self._resync_lock = False + def occupantsClear(self): + """Remove all occupants + + Must be overridden by frontends to clear their own representations of occupants + """ + self.occupants.clear() + def resync(self): if self._resync_lock: return @@ -408,7 +415,7 @@ class QuickChat(quick_widgets.QuickWidget): self.historyPrint(callback=self._resyncComplete, profile=self.profile) return if self.type == C.CHAT_GROUP: - self.occupants.clear() + self.occupantsClear() self.host.bridge.mucOccupantsGet( unicode(self.target), self.profile, callback=self.updateOccupants, errback=log.error)