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.
This commit is contained in:
Joshua Goins
2025-05-24 09:55:52 -04:00
parent 4167f55ad8
commit 86fd2e8e1e
2 changed files with 18 additions and 8 deletions

View File

@@ -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
}
}

View File

@@ -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);
}
}
}