diff libervia/web/pages/chat/_browser/__init__.py @ 1623:fdb5689fb826

browser (chat): Update following template change + some cleaning: - Some templates have been moved from `chat` to `components` to be re-used, this patch adapt the code consequently. - Remove now unused `select` page.
author Goffi <goffi@goffi.org>
date Wed, 21 May 2025 15:57:21 +0200
parents 3a60bf3762ef
children
line wrap: on
line diff
--- a/libervia/web/pages/chat/_browser/__init__.py	Thu May 15 17:52:59 2025 +0200
+++ b/libervia/web/pages/chat/_browser/__init__.py	Wed May 21 15:57:21 2025 +0200
@@ -258,8 +258,8 @@
         self.direct_messages_tpl = Template("chat/direct_messages.html")
         self.message_tpl = Template("chat/message.html")
         self.extra_menu_tpl = Template("chat/extra_menu.html")
-        self.reactions_tpl = Template("chat/reactions.html")
-        self.reactions_details_tpl = Template("chat/reactions_details.html")
+        self.reactions_tpl = Template("components/reactions.html")
+        self.reactions_details_tpl = Template("components/reactions_details.html")
         self.url_preview_control_tpl = Template("components/url_preview_control.html")
         self.url_preview_tpl = Template("components/url_preview.html")
         self.new_messages_marker_elt = Template("chat/new_messages_marker.html").get_elt()
@@ -541,8 +541,9 @@
                 log.debug(f"Message {uid} found, new reactions: {reactions}")
                 reactions_elt = self.reactions_tpl.get_elt(
                     {
-                        "chat_type": chat_type,
-                        "own_local_jid": str(own_local_jid),
+                        "own_jid": str(
+                            own_local_jid if chat_type == "group" else own_local_jid.bare
+                        ),
                         "reactions": reactions
                     })
                 reactions_wrapper_elt.clear()
@@ -867,16 +868,16 @@
             "", "", -2, True, {"thread_id": thread_id}
         )
         for message_data in history_data:
-            uid, timestamp, from_jid, to_jid, message_data, subject_data, mess_type, extra = message_data
+            uid, timestamp, from_jid_s, to_jid_s, message_data, subject_data, mess_type, extra_s = message_data
             template_data = await self.message_to_template_data(
                 uid,
                 timestamp=timestamp,
-                from_jid=from_jid,
-                to_jid=to_jid,
+                from_jid=jid.JID(from_jid_s),
+                to_jid=jid.JID(to_jid_s),
                 message_data=message_data,
                 subject_data=subject_data,
                 mess_type=mess_type,
-                extra=json.loads(extra)
+                extra=json.loads(extra_s)
             )
             message_elt = self.message_tpl.get_elt(template_data)
             thread_messages_elt <= message_elt