From 4ff3ebe25522bcbf3250490d84bdae15ef1ddcd1 Mon Sep 17 00:00:00 2001 From: miruka Date: Wed, 28 Aug 2019 13:29:49 -0400 Subject: [PATCH] Fix room subtitle for local echoes --- src/python/matrix_client.py | 17 ++++++++++------- src/python/models/items.py | 5 +++-- src/qml/utils.js | 1 + 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/python/matrix_client.py b/src/python/matrix_client.py index c2aaf148..90e31328 100644 --- a/src/python/matrix_client.py +++ b/src/python/matrix_client.py @@ -170,10 +170,12 @@ class MatrixClient(nio.AsyncClient): text = text[1:] if text.startswith("/me ") and not escape: + event_type = nio.RoomMessageEmote.__name__ text = text[len("/me "): ] content = {"body": text, "msgtype": "m.emote"} to_html = HTML_FILTER.from_markdown_inline(text, outgoing=True) else: + event_type = nio.RoomMessageText.__name__ content = {"body": text, "msgtype": "m.text"} to_html = HTML_FILTER.from_markdown(text, outgoing=True) @@ -188,13 +190,14 @@ class MatrixClient(nio.AsyncClient): display_content = content.get("formatted_body") or content["body"] local = Event( - source = None, - client_id = f"echo-{uuid}", - event_id = "", - date = datetime.now(), - content = display_content, - inline_content = HTML_FILTER.filter_inline(display_content), - is_local_echo = True, + source = None, + client_id = f"echo-{uuid}", + event_id = "", + date = datetime.now(), + content = display_content, + inline_content = HTML_FILTER.filter_inline(display_content), + is_local_echo = True, + local_event_type = event_type, sender_id = self.user_id, sender_name = our_info.display_name, diff --git a/src/python/models/items.py b/src/python/models/items.py index 3090798f..7bf95981 100644 --- a/src/python/models/items.py +++ b/src/python/models/items.py @@ -124,7 +124,8 @@ class Event(ModelItem): target_name: str = "" target_avatar: str = "" - is_local_echo: bool = False + is_local_echo: bool = False + local_event_type: str = "" def __post_init__(self) -> None: self.inline_content = HTML_FILTER.filter_inline(self.content) @@ -142,7 +143,7 @@ class Event(ModelItem): @property def event_type(self) -> str: - return type(self.source).__name__ + return self.local_event_type or type(self.source).__name__ @dataclass diff --git a/src/qml/utils.js b/src/qml/utils.js index c5c85b20..ec8eecf2 100644 --- a/src/qml/utils.js +++ b/src/qml/utils.js @@ -61,6 +61,7 @@ function processedEventText(ev) { ) if (text.includes("%2") && ev.target_id) { + print(2) text = text.arg(coloredNameHtml(ev.target_name, ev.target_id)) }