From 687ef5b6bdc4da4e9eab3816ed1329a0ce7b173b Mon Sep 17 00:00:00 2001 From: Goffi Date: Tue, 22 Jan 2019 18:52:16 +0100 Subject: [PATCH] quick frontend (chat): use right type in getOrCreateWidget on new message --- sat_frontends/quick_frontend/quick_app.py | 14 ++++++++++---- sat_frontends/quick_frontend/quick_widgets.py | 4 ++-- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/sat_frontends/quick_frontend/quick_app.py b/sat_frontends/quick_frontend/quick_app.py index 672e0759..85cebc3e 100644 --- a/sat_frontends/quick_frontend/quick_app.py +++ b/sat_frontends/quick_frontend/quick_app.py @@ -674,7 +674,13 @@ class QuickApp(object): 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] - if target.resource and not contact_list.isRoom(target.bare): + + try: + is_room = contact_list.isRoom(target.bare) + except exceptions.NotFound: + is_room = False + + if target.resource and not is_room: # we avoid resource locking, but we must keep resource for private MUC # messages target = target.bare @@ -682,9 +688,9 @@ class QuickApp(object): self.widgets.getOrCreateWidget( quick_chat.QuickChat, target, - type_=C.CHAT_ONE2ONE, - on_new_widget=None, - profile=profile, + type_ = C.CHAT_GROUP if is_room else C.CHAT_ONE2ONE, + on_new_widget = None, + profile = profile, ) if ( diff --git a/sat_frontends/quick_frontend/quick_widgets.py b/sat_frontends/quick_frontend/quick_widgets.py index bede04be..a3aaef41 100644 --- a/sat_frontends/quick_frontend/quick_widgets.py +++ b/sat_frontends/quick_frontend/quick_widgets.py @@ -184,13 +184,13 @@ class QuickWidgetsManager(object): if not "profiles" in _kwargs: _kwargs["profiles"] = None - # on_new_widget tell what to do for the new widget creation + # on_new_widget tells what to do for the new widget creation try: on_new_widget = _kwargs.pop("on_new_widget") except KeyError: on_new_widget = C.WIDGET_NEW - # on_existing_widget tell what to do when the widget already exists + # on_existing_widget tells what to do when the widget already exists try: on_existing_widget = _kwargs.pop("on_existing_widget") except KeyError: