diff options
author | Lucas Fryzek <lucas.fryzek@fryzekconcepts.com> | 2025-01-15 21:14:35 +0000 |
---|---|---|
committer | Lucas Fryzek <lucas.fryzek@fryzekconcepts.com> | 2025-01-15 21:14:35 +0000 |
commit | a34196f2fa184755e0dc336341b8ed92e5d0a398 (patch) | |
tree | 026566161dee7ff20c0d10c6c74f8d33f64e7fa3 /src/message.py | |
parent | 1310a03148eac23db565ca0c6bbd5ae490024637 (diff) |
chat: Improve rendering of messages
Reduces the slowdown from receiving lots of messages at once. TODO look
to see if adding messages can be done without freezing the UI.
Diffstat (limited to 'src/message.py')
-rw-r--r-- | src/message.py | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/message.py b/src/message.py index 7a14483..db50829 100644 --- a/src/message.py +++ b/src/message.py @@ -65,14 +65,22 @@ class WeegtkMessage(Gtk.Box): else: self.avatar.set_text(data["username"]) + if data["type"] == "message_append": + self.avatar.set_visible(False) + self.username.set_visible(False) + first = True + padding_size = self.avatar.get_size() + self.avatar.get_margin_start() + self.avatar.get_margin_end() + # TODO messages no longer should be a list, and there should only be one message per entry + # Remove this for loop and make sure chat only sets message contents as a single string for message in data["text"]: margin = 5 if not first else 0 first = False markuped = self.parse_message(message) msg = Gtk.Label(label=markuped, selectable=True, wrap=True, wrap_mode=Pango.WrapMode.WORD_CHAR, xalign=0, - margin_top=margin, use_markup=True) + margin_top=margin, use_markup=True, + margin_start= padding_size if data["type"] == "message_append" else 0) self.message_list.append(msg) |