Make use of new RoomMember item from libquotient
Depends on https://github.com/quotient-im/libQuotient/pull/695 Currently basic just to show a working implementation using RoomMember. Currently only the room event and search models are moved over. Will change everything else over once the dependent pr is complete.
This commit is contained in:
committed by
Tobias Fella
parent
ece56a55e8
commit
272f49876e
@@ -49,7 +49,7 @@ Loader {
|
||||
text: room.isDirectChat() ? i18nc("@action:inmenu", "Copy user's Matrix ID to Clipboard") : i18nc("@action:inmenu", "Copy Address to Clipboard")
|
||||
icon.name: "edit-copy"
|
||||
onTriggered: if (room.isDirectChat()) {
|
||||
Clipboard.saveText(room.directChatRemoteUser.id);
|
||||
Clipboard.saveText(room.directChatRemoteMember.id);
|
||||
} else if (room.canonicalAlias.length === 0) {
|
||||
Clipboard.saveText(room.id);
|
||||
} else {
|
||||
|
||||
@@ -40,18 +40,9 @@ Loader {
|
||||
/**
|
||||
* @brief The message author.
|
||||
*
|
||||
* This should consist of the following:
|
||||
* - id - The matrix ID of the author.
|
||||
* - isLocalUser - Whether the author is the local user.
|
||||
* - avatarSource - The mxc URL for the author's avatar in the current room.
|
||||
* - avatarMediaId - The media ID of the author's avatar.
|
||||
* - avatarUrl - The mxc URL for the author's avatar.
|
||||
* - displayName - The display name of the author.
|
||||
* - display - The name of the author.
|
||||
* - color - The color for the author.
|
||||
* - object - The Quotient::User object for the author.
|
||||
* A Quotient::RoomMember object.
|
||||
*
|
||||
* @sa Quotient::User
|
||||
* @sa Quotient::RoomMember
|
||||
*/
|
||||
required property var author
|
||||
|
||||
@@ -90,7 +81,7 @@ Loader {
|
||||
}
|
||||
|
||||
component RemoveMessageAction: Kirigami.Action {
|
||||
visible: author.isLocalUser || currentRoom.canSendState("redact")
|
||||
visible: author.isLocalMember || currentRoom.canSendState("redact")
|
||||
text: i18n("Remove")
|
||||
icon.name: "edit-delete-remove"
|
||||
icon.color: "red"
|
||||
@@ -116,7 +107,7 @@ Loader {
|
||||
component ReportMessageAction: Kirigami.Action {
|
||||
text: i18nc("@action:button 'Report' as in 'Report this event to the administrators'", "Report")
|
||||
icon.name: "dialog-warning-symbolic"
|
||||
visible: !author.isLocalUser
|
||||
visible: !author.isLocalMember
|
||||
onTriggered: applicationWindow().pageStack.pushDialogLayer(Qt.createComponent('org.kde.neochat', 'ReportSheet'), {
|
||||
room: currentRoom,
|
||||
eventId: eventId
|
||||
|
||||
@@ -33,7 +33,7 @@ ColumnLayout {
|
||||
Layout.alignment: Qt.AlignHCenter
|
||||
|
||||
onClicked: {
|
||||
RoomManager.resolveResource(root.room.directChatRemoteUser.id, "mention");
|
||||
RoomManager.resolveResource(root.room.directChatRemoteMember.uri)
|
||||
}
|
||||
|
||||
contentItem: KirigamiComponents.Avatar {
|
||||
|
||||
@@ -63,7 +63,7 @@ DelegateContextMenu {
|
||||
}
|
||||
},
|
||||
Kirigami.Action {
|
||||
visible: author.id === currentRoom.localUser.id || currentRoom.canSendState("redact")
|
||||
visible: author.id === currentRoom.localMember.id || currentRoom.canSendState("redact")
|
||||
text: i18n("Remove")
|
||||
icon.name: "edit-delete-remove"
|
||||
icon.color: "red"
|
||||
|
||||
@@ -22,7 +22,7 @@ Kirigami.PlaceholderMessage {
|
||||
|
||||
onClicked: {
|
||||
RoomManager.leaveRoom(root.currentRoom);
|
||||
root.currentRoom.connection.addToIgnoredUsers(root.currentRoom.invitingUser());
|
||||
root.currentRoom.connection.addToIgnoredUsers(root.currentRoom.invitingUserId());
|
||||
}
|
||||
}
|
||||
QQC2.Button {
|
||||
|
||||
@@ -55,7 +55,7 @@ MapQuickItem {
|
||||
width: height
|
||||
height: parent.height / 3 + 1
|
||||
name: root.author.displayName
|
||||
source: root.author.avatarSource
|
||||
source: root.author.avatarUrl
|
||||
color: root.author.color
|
||||
}
|
||||
|
||||
|
||||
@@ -354,7 +354,7 @@ Kirigami.ApplicationWindow {
|
||||
function showUserDetail(user) {
|
||||
Qt.createComponent("org.kde.neochat", "UserDetailDialog").createObject(root.QQC2.ApplicationWindow.window, {
|
||||
room: RoomManager.currentRoom ? RoomManager.currentRoom : null,
|
||||
user: RoomManager.currentRoom ? RoomManager.currentRoom.getUser(user.id) : QmlUtils.getUser(user),
|
||||
user: user,
|
||||
connection: root.connection
|
||||
}).open();
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ DelegateContextMenu {
|
||||
currentRoom.editCache.editId = eventId;
|
||||
currentRoom.mainCache.replyId = "";
|
||||
}
|
||||
visible: author.isLocalUser && (root.messageComponentType === MessageComponentType.Emote || root.messageComponentType === MessageComponentType.Message)
|
||||
visible: author.isLocalMember && (root.messageComponentType === MessageComponentType.Emote || root.messageComponentType === MessageComponentType.Message)
|
||||
},
|
||||
DelegateContextMenu.ReplyMessageAction {},
|
||||
Kirigami.Action {
|
||||
|
||||
@@ -219,7 +219,7 @@ QQC2.ScrollView {
|
||||
|
||||
onClicked: {
|
||||
userDelegate.highlighted = true;
|
||||
RoomManager.resolveResource(userDelegate.userId, "mention");
|
||||
RoomManager.resolveResource(root.room.member(userDelegate.userId).uri)
|
||||
}
|
||||
|
||||
contentItem: RowLayout {
|
||||
|
||||
@@ -19,8 +19,21 @@ Kirigami.Dialog {
|
||||
// This dialog is sometimes used outside the context of a room, e.g., when scanning a user's QR code.
|
||||
// Make sure that code is prepared to deal with this property being null
|
||||
property NeoChatRoom room
|
||||
|
||||
/**
|
||||
* @brief The user's profile object.
|
||||
*
|
||||
* Required to interact with the profile and perform action like ignoring.
|
||||
*/
|
||||
property var user
|
||||
|
||||
/**
|
||||
* @brief The RoomMember object for the user in the current room.
|
||||
*
|
||||
* Required to visualise the user.
|
||||
*/
|
||||
property var member: root.room.member(user.id)
|
||||
|
||||
property NeoChatConnection connection
|
||||
|
||||
leftPadding: 0
|
||||
@@ -48,9 +61,9 @@ Kirigami.Dialog {
|
||||
Layout.preferredWidth: Kirigami.Units.iconSizes.huge
|
||||
Layout.preferredHeight: Kirigami.Units.iconSizes.huge
|
||||
|
||||
name: root.user.displayName
|
||||
source: root.user.avatarSource
|
||||
color: root.user.color
|
||||
name: root.member.displayName
|
||||
source: root.member.avatarUrl
|
||||
color: root.member.color
|
||||
}
|
||||
|
||||
ColumnLayout {
|
||||
@@ -69,7 +82,7 @@ Kirigami.Dialog {
|
||||
|
||||
Kirigami.SelectableLabel {
|
||||
textFormat: TextEdit.PlainText
|
||||
text: root.user.id
|
||||
text: root.member.id
|
||||
}
|
||||
}
|
||||
QQC2.AbstractButton {
|
||||
@@ -78,16 +91,16 @@ Kirigami.Dialog {
|
||||
contentItem: Barcode {
|
||||
id: barcode
|
||||
barcodeType: Barcode.QRCode
|
||||
content: "https://matrix.to/#/" + root.user.id
|
||||
content: "https://matrix.to/#/" + root.member.id
|
||||
}
|
||||
|
||||
onClicked: {
|
||||
let map = qrMaximizeComponent.createObject(parent, {
|
||||
text: barcode.content,
|
||||
title: root.user.displayName,
|
||||
subtitle: root.user.id,
|
||||
avatarColor: root.user.color,
|
||||
avatarSource: root.user.avatarSource
|
||||
title: root.member.displayName,
|
||||
subtitle: root.member.id,
|
||||
avatarColor: root.member.color,
|
||||
avatarSource: root.member.avatarUrl,
|
||||
});
|
||||
root.close();
|
||||
map.open();
|
||||
@@ -104,46 +117,46 @@ Kirigami.Dialog {
|
||||
}
|
||||
|
||||
FormCard.FormButtonDelegate {
|
||||
visible: !root.user.isLocalUser && !!root.user.object
|
||||
visible: !root.member.isLocalMember
|
||||
action: Kirigami.Action {
|
||||
text: !!root.user.object && root.connection.isIgnored(root.user.object) ? i18n("Unignore this user") : i18n("Ignore this user")
|
||||
text: !!root.user && root.connection.isIgnored(root.user) ? i18n("Unignore this user") : i18n("Ignore this user")
|
||||
icon.name: "im-invisible-user"
|
||||
onTriggered: {
|
||||
root.close();
|
||||
root.connection.isIgnored(root.user.object) ? root.connection.removeFromIgnoredUsers(root.user.object) : root.connection.addToIgnoredUsers(root.user.object);
|
||||
root.connection.isIgnored(root.user) ? root.connection.removeFromIgnoredUsers(root.user) : root.connection.addToIgnoredUsers(root.user);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FormCard.FormButtonDelegate {
|
||||
visible: root.room && !root.user.isLocalUser && room.canSendState("kick") && room.containsUser(root.user.id) && room.getUserPowerLevel(root.user.id) < room.getUserPowerLevel(root.connection.localUser.id)
|
||||
visible: root.room && !root.member.isLocalMember && room.canSendState("kick") && room.containsUser(root.member.id) && room.getUserPowerLevel(root.member.id) < room.getUserPowerLevel(root.room.localMember.id)
|
||||
|
||||
action: Kirigami.Action {
|
||||
text: i18n("Kick this user")
|
||||
icon.name: "im-kick-user"
|
||||
onTriggered: {
|
||||
root.room.kickMember(root.user.id);
|
||||
root.room.kickMember(root.member.id);
|
||||
root.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FormCard.FormButtonDelegate {
|
||||
visible: root.room && !root.user.isLocalUser && room.canSendState("invite") && !room.containsUser(root.user.id)
|
||||
visible: root.room && !root.member.isLocalMember && room.canSendState("invite") && !room.containsUser(root.member.id)
|
||||
|
||||
action: Kirigami.Action {
|
||||
enabled: root.room && !root.room.isUserBanned(root.user.id)
|
||||
enabled: root.room && !root.room.isUserBanned(root.member.id)
|
||||
text: i18n("Invite this user")
|
||||
icon.name: "list-add-user"
|
||||
onTriggered: {
|
||||
root.room.inviteToRoom(root.user.id);
|
||||
root.room.inviteToRoom(root.member.id);
|
||||
root.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FormCard.FormButtonDelegate {
|
||||
visible: root.room && !root.user.isLocalUser && room.canSendState("ban") && !room.isUserBanned(root.user.id) && room.getUserPowerLevel(root.user.id) < room.getUserPowerLevel(root.room.connection.localUser.id)
|
||||
visible: root.room && !root.member.isLocalMember && room.canSendState("ban") && !room.isUserBanned(root.member.id) && room.getUserPowerLevel(root.member.id) < room.getUserPowerLevel(root.room.localMember.id)
|
||||
|
||||
action: Kirigami.Action {
|
||||
text: i18n("Ban this user")
|
||||
@@ -152,7 +165,7 @@ Kirigami.Dialog {
|
||||
onTriggered: {
|
||||
(root.QQC2.ApplicationWindow.window as Kirigami.ApplicationWindow).pageStack.pushDialogLayer(Qt.createComponent('org.kde.neochat', 'BanSheet'), {
|
||||
room: root.room,
|
||||
userId: root.user.id
|
||||
userId: root.member.id
|
||||
}, {
|
||||
title: i18nc("@title", "Ban User"),
|
||||
width: Kirigami.Units.gridUnit * 25
|
||||
@@ -163,14 +176,14 @@ Kirigami.Dialog {
|
||||
}
|
||||
|
||||
FormCard.FormButtonDelegate {
|
||||
visible: root.room && !root.user.isLocalUser && room.canSendState("ban") && room.isUserBanned(root.user.id)
|
||||
visible: root.room && !root.member.isLocalMember && room.canSendState("ban") && room.isUserBanned(root.member.id)
|
||||
|
||||
action: Kirigami.Action {
|
||||
text: i18n("Unban this user")
|
||||
icon.name: "im-irc"
|
||||
icon.color: Kirigami.Theme.negativeTextColor
|
||||
onTriggered: {
|
||||
root.room.unban(root.user.id);
|
||||
root.room.unban(root.member.id);
|
||||
root.close();
|
||||
}
|
||||
}
|
||||
@@ -184,8 +197,8 @@ Kirigami.Dialog {
|
||||
onTriggered: {
|
||||
let dialog = powerLevelDialog.createObject(this, {
|
||||
room: root.room,
|
||||
userId: root.user.id,
|
||||
powerLevel: root.room.getUserPowerLevel(root.user.id)
|
||||
userId: root.member.id,
|
||||
powerLevel: root.room.getUserPowerLevel(root.member.id)
|
||||
});
|
||||
dialog.open();
|
||||
root.close();
|
||||
@@ -201,7 +214,7 @@ Kirigami.Dialog {
|
||||
}
|
||||
|
||||
FormCard.FormButtonDelegate {
|
||||
visible: root.room && (root.user.isLocalUser || room.canSendState("redact"))
|
||||
visible: root.room && (root.member.isLocalUser || room.canSendState("redact"))
|
||||
|
||||
action: Kirigami.Action {
|
||||
text: i18n("Remove recent messages by this user")
|
||||
@@ -210,7 +223,7 @@ Kirigami.Dialog {
|
||||
onTriggered: {
|
||||
applicationWindow().pageStack.pushDialogLayer(Qt.createComponent('org.kde.neochat', 'RemoveSheet'), {
|
||||
room: root.room,
|
||||
userId: root.user.id
|
||||
userId: root.member.id
|
||||
}, {
|
||||
title: i18nc("@title", "Remove Messages"),
|
||||
width: Kirigami.Units.gridUnit * 25
|
||||
@@ -221,12 +234,12 @@ Kirigami.Dialog {
|
||||
}
|
||||
|
||||
FormCard.FormButtonDelegate {
|
||||
visible: !root.user.isLocalUser
|
||||
visible: !root.member.isLocalMember
|
||||
action: Kirigami.Action {
|
||||
text: root.connection.directChatExists(root.user.object) ? i18nc("%1 is the name of the user.", "Chat with %1", root.user.escapedDisplayName) : i18n("Invite to private chat")
|
||||
icon.name: "document-send"
|
||||
onTriggered: {
|
||||
root.connection.openOrCreateDirectChat(root.user.object);
|
||||
root.room.connection.openOrCreateDirectChat(root.user);
|
||||
root.close();
|
||||
}
|
||||
}
|
||||
@@ -237,7 +250,7 @@ Kirigami.Dialog {
|
||||
text: i18n("Copy link")
|
||||
icon.name: "username-copy"
|
||||
onTriggered: {
|
||||
Clipboard.saveText("https://matrix.to/#/" + root.user.id);
|
||||
Clipboard.saveText("https://matrix.to/#/" + root.member.id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user