From a34196f2fa184755e0dc336341b8ed92e5d0a398 Mon Sep 17 00:00:00 2001 From: Lucas Fryzek Date: Wed, 15 Jan 2025 21:14:35 +0000 Subject: 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. --- src/message.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/message.py') 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) -- cgit