Mercurial > libervia-desktop-kivy
diff cagou/plugins/plugin_wid_chat.py @ 356:307c2501d8b2
chat: keep as many instances of opened chat as there are active WHWrapper, instead of just one:
Chat instances can be shown on any WHWrapper, even in all at the same time, so we keep as
many instances as active wrapper to avoid unnecessary widget (re)creation
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 17 Jan 2020 20:35:57 +0100 |
parents | aa860c10acfc |
children | 4d3a0c4f2430 |
line wrap: on
line diff
--- a/cagou/plugins/plugin_wid_chat.py Fri Jan 17 20:33:43 2020 +0100 +++ b/cagou/plugins/plugin_wid_chat.py Fri Jan 17 20:35:57 2020 +0100 @@ -767,13 +767,13 @@ if not self.sync: self.resync() - def onDelete(self): + def onDelete(self, **kwargs): # we always keep one widget, so it's available when swiping # TODO: delete all widgets when chat is closed nb_instances = sum(1 for _ in self.host.widgets.getWidgetInstances(self)) - if nb_instances > 1: - return super(Chat, self).onDelete() - else: + # we want to keep at least one instance of Chat by WHWrapper + nb_to_keep = len(G.host.widgets_handler.children) + if nb_instances <= nb_to_keep: return False def _history_unlock(self, __):