Create NeochatRoomMember as a shim for RoomMember

The intention is that NeochatRoomMember can be created passed to QML and then be fully managed by it. It effectively just grabs the current RoomMember, calls the correct function then discards it so that we don't end up trying to access an already deleted state event.
This commit is contained in:
James Graham
2024-07-27 08:46:56 +00:00
parent 4d9452b862
commit 11fd4f88ec
22 changed files with 363 additions and 112 deletions

View File

@@ -20,7 +20,7 @@ QQC2.Control {
*
* @sa Quotient::RoomMember
*/
required property RoomMember author
required property NeochatRoomMember author
/**
* @brief The timestamp of the message.

View File

@@ -26,7 +26,7 @@ TimelineDelegate {
/**
* @brief The message author.
*/
required property RoomMember author
required property NeochatRoomMember author
width: parent?.width
rightPadding: NeoChatConfig.compactLayout && root.ListView.view.width >= Kirigami.Units.gridUnit * 20 ? Kirigami.Units.gridUnit * 2 + Kirigami.Units.largeSpacing : Kirigami.Units.largeSpacing
@@ -88,7 +88,7 @@ TimelineDelegate {
QtObject {
id: _private
function showMessageMenu() {
RoomManager.viewEventMenu(root.eventId, root.room, "");
RoomManager.viewEventMenu(root.eventId, root.room, root.author, "");
}
}
}

View File

@@ -50,7 +50,7 @@ TimelineDelegate {
*
* @sa Quotient::RoomMember
*/
required property var author
required property NeochatRoomMember author
/**
* @brief The model to visualise the content of the message.
@@ -365,7 +365,7 @@ TimelineDelegate {
property bool showUserMessageOnRight: NeoChatConfig.showLocalMessagesOnRight && root.author.isLocalMember && !NeoChatConfig.compactLayout && !root.alwaysFillWidth
function showMessageMenu() {
RoomManager.viewEventMenu(root.eventId, root.room, root.selectedText);
RoomManager.viewEventMenu(root.eventId, root.room, root.author, root.selectedText);
}
}
}

View File

@@ -48,12 +48,13 @@ RowLayout {
source: root.author?.avatarUrl ?? ""
name: root.author?.displayName ?? ""
color: root.author?.color ?? undefined
color: root.author?.color ?? Kirigami.Theme.highlightColor
MouseArea {
anchors.fill: parent
enabled: root.author
cursorShape: Qt.PointingHandCursor
onClicked: RoomManager.resolveResource("https://matrix.to/#/" + root.author.id)
onClicked: RoomManager.resolveResource("https://matrix.to/#/" + root.author?.id ?? "")
}
}
@@ -61,7 +62,7 @@ RowLayout {
id: label
Layout.alignment: Qt.AlignVCenter
Layout.fillWidth: true
text: `<style>a {text-decoration: none; color: ${Kirigami.Theme.textColor};}</style><a href="https://matrix.to/#/${root.author.id}">${root.authorDisplayName}</a> ${root.text}`
text: `<style>a {text-decoration: none; color: ${Kirigami.Theme.textColor};}</style><a href="https://matrix.to/#/${root.author?.id ?? ""}">${root.authorDisplayName}</a> ${root.text}`
wrapMode: Text.WordWrap
textFormat: Text.RichText
onLinkActivated: link => RoomManager.resolveResource(link)