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 bool NeoChatRoom::containsUser(const QString &userID) const
{ {
#ifdef QUOTIENT_07
return memberState(userID) != Membership::Leave;
#else
auto u = Room::user(userID); auto u = Room::user(userID);
if (!u) { if (!u) {
@@ -927,6 +930,7 @@ bool NeoChatRoom::containsUser(const QString &userID) const
} }
return Room::memberJoinState(u) != JoinState::Leave; return Room::memberJoinState(u) != JoinState::Leave;
#endif
} }
bool NeoChatRoom::canSendEvent(const QString &eventType) const bool NeoChatRoom::canSendEvent(const QString &eventType) const

View File

@@ -49,9 +49,6 @@ Kirigami.ScrollablePage {
} }
ListView { ListView {
Layout.fillWidth: true
Layout.fillHeight: true
id: userDictListView id: userDictListView
clip: true clip: true
@@ -71,60 +68,38 @@ Kirigami.ScrollablePage {
text: i18n("No users available") text: i18n("No users available")
} }
delegate: Kirigami.AbstractListItem { delegate: Kirigami.BasicListItem {
id: delegate id: delegate
property bool inRoom: room && room.containsUser(userID) property bool inRoom: room && room.containsUser(userID)
topPadding: Kirigami.Units.largeSpacing label: model.name
bottomPadding: Kirigami.Units.largeSpacing subtitle: model.userID
contentItem: RowLayout { leading: Kirigami.Avatar {
Kirigami.Avatar { implicitWidth: height
Layout.preferredWidth: height source: model.avatar ? ("image://mxc/" + model.avatar) : ""
Layout.fillHeight: true 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) : "" onToggled: {
name: model.name if (inRoom) {
} checked = true
} else {
ColumnLayout { room.inviteToRoom(model.userID);
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);
applicationWindow().pageStack.layers.pop(); 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
} }
} }
} }