diff --git a/src/backend/html_markdown.py b/src/backend/html_markdown.py
index beafee41..69f8bac3 100644
--- a/src/backend/html_markdown.py
+++ b/src/backend/html_markdown.py
@@ -312,8 +312,8 @@ class HTMLProcessor:
}}
username_link_regexes = [re.compile(r) for r in [
- rf"(?{re.escape(name)})(?!\w)(?P)"
- for name in (display_name_mentions or {})
+ rf"(?{re.escape(name or user_id)})(?!\w)(?P)"
+ for user_id, name in (display_name_mentions or {}).items()
]]
return {
@@ -495,8 +495,8 @@ class HTMLProcessor:
el.attrib["href"] = f"https://matrix.to/#/{el.attrib['href']}"
return el
- for name, user_id in (display_name_mentions or {}).items():
- if unquote(el.attrib["href"]) == name:
+ for user_id, name in (display_name_mentions or {}).items():
+ if unquote(el.attrib["href"]) == (name or user_id):
el.attrib["href"] = f"https://matrix.to/#/{user_id}"
return el
diff --git a/src/backend/matrix_client.py b/src/backend/matrix_client.py
index fce14613..7980aefa 100644
--- a/src/backend/matrix_client.py
+++ b/src/backend/matrix_client.py
@@ -512,7 +512,7 @@ class MatrixClient(nio.AsyncClient):
self,
room_id: str,
text: str,
- display_name_mentions: Optional[Dict[str, str]] = None, # {name: id}
+ display_name_mentions: Optional[Dict[str, str]] = None, # {id: name}
reply_to_event_id: Optional[str] = None,
) -> None:
"""Send a markdown `m.text` or `m.notice` (with `/me`) message ."""
diff --git a/src/gui/Pages/Chat/AutoCompletion/UserAutoCompletion.qml b/src/gui/Pages/Chat/AutoCompletion/UserAutoCompletion.qml
index 0cba11f8..7160beb9 100644
--- a/src/gui/Pages/Chat/AutoCompletion/UserAutoCompletion.qml
+++ b/src/gui/Pages/Chat/AutoCompletion/UserAutoCompletion.qml
@@ -16,7 +16,7 @@ HListView {
property int replacementStart: -1
property int replacementEnd: -1
property bool autoOpenCompleted: false
- property var usersCompleted: ({}) // {displayName: userId}
+ property var usersCompleted: ({}) // {userId: displayName}
readonly property bool autoOpen: {
if (autoOpenCompleted) return true
@@ -70,7 +70,7 @@ HListView {
function accept() {
if (currentIndex !== -1) {
const member = model.get(currentIndex)
- usersCompleted[member.display_name] = member.id
+ usersCompleted[member.id] = member.display_name
usersCompletedChanged()
}
@@ -165,9 +165,9 @@ HListView {
function onTextChanged() {
let changed = false
- for (const displayName of Object.keys(root.usersCompleted)) {
- if (! root.textArea.text.includes(displayName)) {
- delete root.usersCompleted[displayName]
+ for (const [id, name] of Object.entries(root.usersCompleted)) {
+ if (! root.textArea.text.includes(name)) {
+ delete root.usersCompleted[id]
changed = true
}
}