diff frontends/src/quick_frontend/quick_app.py @ 2040:f607349a01a4

quick frontend (chat): fixed messageNew signal dispatching when several widgets are handling the target
author Goffi <goffi@goffi.org>
date Sun, 21 Aug 2016 17:04:33 +0200
parents db3bbbd745e4
children 2e948c228643
line wrap: on
line diff
--- a/frontends/src/quick_frontend/quick_app.py	Sun Aug 21 17:03:18 2016 +0200
+++ b/frontends/src/quick_frontend/quick_app.py	Sun Aug 21 17:04:33 2016 +0200
@@ -479,7 +479,8 @@
         from_me = from_jid.bare == self.profiles[profile].whoami.bare
         target = to_jid if from_me else from_jid
         contact_list = self.contact_lists[profile]
-        chat_widget = self.widgets.getOrCreateWidget(quick_chat.QuickChat, target, type_=C.CHAT_ONE2ONE, on_new_widget=None, profile=profile)
+        # we want to be sure to have at least one QuickChat instance
+        self.widgets.getOrCreateWidget(quick_chat.QuickChat, target, type_=C.CHAT_ONE2ONE, on_new_widget=None, profile=profile)
 
         self.current_action_ids = set() # FIXME: to be removed
         self.current_action_ids_cb = {} # FIXME: to be removed
@@ -489,9 +490,9 @@
             #     presence information and which are not in roster
             contact_list.setContact(from_jid)
 
-        # we display the message in the widget
-
-        chat_widget.messageNew(uid, timestamp, from_jid, target, msg, subject, type_, extra, profile)
+        # we dispatch the message in the widgets
+        for widget in self.widgets.getWidgets(quick_chat.QuickChat, target=target, profiles=(profile,)):
+            widget.messageNew(uid, timestamp, from_jid, target, msg, subject, type_, extra, profile)
 
     def messageStateHandler(self, uid, status, profile):
         for widget in self.widgets.getWidgets(quick_chat.QuickChat, profiles=(profile,)):