Commit 4defa977 authored by Nico's avatar Nico
Browse files

Don't expect messages to always have text

Some messages are notices that don't carry any text (responses to forum invitations for example).

```
Traceback (most recent call last):
  File "/usr/share/briar-gtk/briar_gtk/containers/private_chat.py", line 101, in _add_message
    message_widget = PrivateMessageWidget(self._contact_name, message)
  File "/usr/share/briar-gtk/briar_gtk/widgets/private_message.py", line 18, in __init__
    self._setup_view(contact_name, message)
  File "/usr/share/briar-gtk/briar_gtk/widgets/private_message.py", line 34, in _setup_view
    message["text"])
KeyError: 'text'
```

Fixes #56.
parent 56378e12
Pipeline #4644 passed with stage
in 4 minutes and 16 seconds
...@@ -98,9 +98,15 @@ class PrivateChatContainer(Container): ...@@ -98,9 +98,15 @@ class PrivateChatContainer(Container):
self._signals.append(signal_id) self._signals.append(signal_id)
def _add_message(self, message): def _add_message(self, message):
if self._is_not_message(message):
return
message_widget = PrivateMessageWidget(self._contact_name, message) message_widget = PrivateMessageWidget(self._contact_name, message)
self._messages_box.add(message_widget) self._messages_box.add(message_widget)
@staticmethod
def _is_not_message(message):
return "text" not in message
def _add_message_async(self, message): def _add_message_async(self, message):
if message["data"]["contactId"] == self._contact_id: if message["data"]["contactId"] == self._contact_id:
GLib.idle_add(self._add_message_and_scroll, message["data"]) GLib.idle_add(self._add_message_and_scroll, message["data"])
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment