Improve Invitation Flow

- Update the conatainsUser function to use memberState so that invites do not show up as being in the leave state.
- Update the InviteUser page to use Kirigami.BasicListItem and make the invite button remain visible but be untoggleable when the if user has already been invited.

closes network/neochat#202
This commit is contained in:
James Graham
2023-04-29 17:13:24 +00:00
committed by Tobias Fella
parent d844945453
commit e8166f3433
2 changed files with 28 additions and 49 deletions

View File

@@ -920,6 +920,9 @@ void NeoChatRoom::toggleReaction(const QString &eventId, const QString &reaction
bool NeoChatRoom::containsUser(const QString &userID) const
{
#ifdef QUOTIENT_07
return memberState(userID) != Membership::Leave;
#else
auto u = Room::user(userID);
if (!u) {
@@ -927,6 +930,7 @@ bool NeoChatRoom::containsUser(const QString &userID) const
}
return Room::memberJoinState(u) != JoinState::Leave;
#endif
}
bool NeoChatRoom::canSendEvent(const QString &eventType) const

View File

@@ -49,9 +49,6 @@ Kirigami.ScrollablePage {
}
ListView {
Layout.fillWidth: true
Layout.fillHeight: true
id: userDictListView
clip: true
@@ -71,60 +68,38 @@ Kirigami.ScrollablePage {
text: i18n("No users available")
}
delegate: Kirigami.AbstractListItem {
delegate: Kirigami.BasicListItem {
id: delegate
property bool inRoom: room && room.containsUser(userID)
topPadding: Kirigami.Units.largeSpacing
bottomPadding: Kirigami.Units.largeSpacing
label: model.name
subtitle: model.userID
contentItem: RowLayout {
Kirigami.Avatar {
Layout.preferredWidth: height
Layout.fillHeight: true
leading: Kirigami.Avatar {
implicitWidth: height
source: model.avatar ? ("image://mxc/" + model.avatar) : ""
name: model.name
}
trailing: QQC2.ToolButton {
id: inviteButton
icon.name: "document-send"
text: i18n("Send invitation")
checkable: true
checked: inRoom
opacity: inRoom ? 0.5 : 1
source: model.avatar ? ("image://mxc/" + model.avatar) : ""
name: model.name
}
ColumnLayout {
Layout.fillWidth: true
Layout.fillHeight: true
spacing: 0
Kirigami.Heading {
Layout.fillWidth: true
Layout.fillHeight: true
level: 3
text: name
textFormat: Text.PlainText
elide: Text.ElideRight
wrapMode: Text.NoWrap
}
QQC2.Label {
Layout.fillWidth: true
Layout.fillHeight: true
text: userID
textFormat: Text.PlainText
elide: Text.ElideRight
wrapMode: Text.NoWrap
}
}
QQC2.ToolButton {
visible: !inRoom
icon.name: "document-send"
text: i18n("Send invitation")
onClicked: {
room.inviteToRoom(userID);
onToggled: {
if (inRoom) {
checked = true
} else {
room.inviteToRoom(model.userID);
applicationWindow().pageStack.layers.pop();
}
}
QQC2.ToolTip.text: !inRoom ? text : i18n("User is either already a member or has been invited")
QQC2.ToolTip.visible: inviteButton.hovered
QQC2.ToolTip.delay: Kirigami.Units.toolTipDelay
}
}
}