From 86fd2e8e1e2e706bdacfc5e74e850d81ca1cbcd5 Mon Sep 17 00:00:00 2001 From: Joshua Goins Date: Sat, 24 May 2025 09:55:52 -0400 Subject: [PATCH] Improve the UX for rooms that don't have a canonical alias This was discovered none other than Bug Catcher Nate, while in the TWiKS room. That room doesn't have a canonical alias set (yet) and that exposed some UX problems around aliases in NeoChat. First, the non-canonical alias isn't shown in the info drawer despite being the only alias available. This is something that Element actually does, and now NeoChat does too. Second, NeoChat will try to copy the room's internal Matrix ID (which is not that great) to the clipboard because it looks for the canonical alias. Surprisingly, Element also does this but now NeoChat doesn't. --- src/libneochat/qml/GroupChatDrawerHeader.qml | 9 +++++++-- src/rooms/RoomContextMenu.qml | 17 +++++++++++------ 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/libneochat/qml/GroupChatDrawerHeader.qml b/src/libneochat/qml/GroupChatDrawerHeader.qml index 54a898e84..bcf239040 100644 --- a/src/libneochat/qml/GroupChatDrawerHeader.qml +++ b/src/libneochat/qml/GroupChatDrawerHeader.qml @@ -19,6 +19,11 @@ ColumnLayout { */ required property NeoChatRoom room + /** + * @brief The canonical alias of the room, if it exists. Otherwise falls back to the first available alias. + */ + readonly property var roomAlias: room.aliases[0] + Layout.fillWidth: true RowLayout { @@ -73,8 +78,8 @@ ColumnLayout { Layout.fillWidth: true font: Kirigami.Theme.smallFont textFormat: TextEdit.PlainText - visible: root.room && root.room.canonicalAlias - text: root.room && root.room.canonicalAlias ? root.room.canonicalAlias : "" + visible: root.room && root.roomAlias + text: root.room && root.roomAlias ? root.roomAlias : "" color: Kirigami.Theme.disabledTextColor } } diff --git a/src/rooms/RoomContextMenu.qml b/src/rooms/RoomContextMenu.qml index 829ab2b2e..691ce3d61 100644 --- a/src/rooms/RoomContextMenu.qml +++ b/src/rooms/RoomContextMenu.qml @@ -125,12 +125,17 @@ KirigamiComponents.ConvergentContextMenu { QQC2.Action { text: room.isDirectChat() ? i18nc("@action:inmenu", "Copy user's Matrix ID") : i18nc("@action:inmenu", "Copy Room Address") icon.name: "edit-copy" - onTriggered: if (room.isDirectChat()) { - Clipboard.saveText(room.directChatRemoteMember.id); - } else if (room.canonicalAlias.length === 0) { - Clipboard.saveText(room.id); - } else { - Clipboard.saveText(room.canonicalAlias); + onTriggered: { + // The canonical alias (if it exists) otherwise the first available alias + const firstAlias = room.aliases[0]; + + if (room.isDirectChat()) { + Clipboard.saveText(room.directChatRemoteMember.id); + } else if (!firstAlias) { + Clipboard.saveText(room.id); + } else { + Clipboard.saveText(firstAlias); + } } }