comparison cagou/plugins/plugin_wid_chat.py @ 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 284cb5c467b0
comparison
equal deleted inserted replaced
185:ab3f5173ef5c 186:a826c70beda2
367 or when one2one chat is not visible. A note is also there when widget 367 or when one2one chat is not visible. A note is also there when widget
368 is not visible. 368 is not visible.
369 For group chat, note will be added on mention, with a desktop notification if 369 For group chat, note will be added on mention, with a desktop notification if
370 window has not focus. 370 window has not focus.
371 """ 371 """
372 visible_clones = [w for w in G.host.getVisibleList(self.__class__) if w.target == self.target]
373 if len(visible_clones) > 1 and visible_clones.index(self) > 0:
374 # to avoid multiple notifications in case of multiple cloned widgets
375 # we only handle first clone
376 return
377 is_visible = bool(visible_clones)
372 if self.type == C.CHAT_ONE2ONE: 378 if self.type == C.CHAT_ONE2ONE:
373 is_visible = self.target in [w.target for w in G.host.getVisibleList(self.__class__)]
374 if (not Window.focus or not is_visible) and not mess_data.history: 379 if (not Window.focus or not is_visible) and not mess_data.history:
375 notif_msg = self._get_notif_msg(mess_data) 380 notif_msg = self._get_notif_msg(mess_data)
376 G.host.desktop_notif( 381 G.host.desktop_notif(
377 notif_msg, 382 notif_msg,
378 title=_(u"private message")) 383 title=_(u"private message"))