changeset 186:a826c70beda2

chat: avoid multiple notifications when there are several cloned chats (i.e. with same target)
author Goffi <goffi@goffi.org>
date Fri, 11 May 2018 20:08:09 +0200
parents ab3f5173ef5c
children d11df7793399
files cagou/plugins/plugin_wid_chat.py
diffstat 1 files changed, 6 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/cagou/plugins/plugin_wid_chat.py	Fri May 11 20:07:17 2018 +0200
+++ b/cagou/plugins/plugin_wid_chat.py	Fri May 11 20:08:09 2018 +0200
@@ -369,8 +369,13 @@
         For group chat, note will be added on mention, with a desktop notification if
         window has not focus.
         """
+        visible_clones = [w for w in G.host.getVisibleList(self.__class__) if w.target == self.target]
+        if len(visible_clones) > 1 and visible_clones.index(self) > 0:
+            # to avoid multiple notifications in case of multiple cloned widgets
+            # we only handle first clone
+            return
+        is_visible = bool(visible_clones)
         if self.type == C.CHAT_ONE2ONE:
-            is_visible = self.target in [w.target for w in G.host.getVisibleList(self.__class__)]
             if (not Window.focus or not is_visible) and not mess_data.history:
                 notif_msg = self._get_notif_msg(mess_data)
                 G.host.desktop_notif(