Shorten reply text for room list last messages

For rooms in the room list, when the last message displayed under the
room name is a reply, change the
"In reply to @foo:example.org: original message... ⏎" text shown
before the actual reply content to just "↩ foo: ".

This lets the user preview the actual interesting part of the message,
instead of a long "In reply to" that takes all the available width.
This commit is contained in:
miruka 2021-04-10 04:02:16 -04:00
parent 20e8a19017
commit 208e08ed2a

View File

@ -484,7 +484,15 @@ class HTMLProcessor:
if el.tag != "mx-reply":
return el
el.tail = f" ⏎⏎ {el.tail or ''}"
try:
user_id = el.find("blockquote").findall("a")[1].text
text = f"{user_id[1:].split(':')[0]}: " # U+21A9 arrow
except (AttributeError, IndexError):
text = "" # U+21A9 arrow
el.clear()
el.tag = "span"
el.text = text
return el