feat: Block users who sent invites

This commit is contained in:
krille-chan 2023-12-26 17:03:40 +01:00
parent b71023954d
commit 991277d5f5
No known key found for this signature in database
2 changed files with 40 additions and 18 deletions

View file

@ -2387,5 +2387,6 @@
"joinSpace": "Join space",
"publicSpaces": "Public spaces",
"addChatOrSubSpace": "Add chat or sub space",
"subspace": "Subspace"
"subspace": "Subspace",
"decline": "Decline"
}

View file

@ -41,25 +41,40 @@ class ChatListItem extends StatelessWidget {
if (room.membership == Membership.invite) {
final inviterId =
room.getState(EventTypes.RoomMember, room.client.userID!)?.senderId;
final profile = inviterId == null
? null
: await showFutureLoadingDialog(
context: context,
future: () => room.client.getProfileFromUserId(inviterId),
);
final consent = await showOkCancelAlertDialog(
final inviteAction = await showModalActionSheet<InviteActions>(
context: context,
title: L10n.of(context)!.inviteForMe,
message: L10n.of(context)!.youInvitedBy(
profile?.result?.displayName ??
profile?.result?.userId.localpart ??
L10n.of(context)!.user,
),
okLabel: L10n.of(context)!.joinRoom,
cancelLabel: L10n.of(context)!.delete,
barrierDismissible: false,
message: room.isDirectChat
? L10n.of(context)!.invitePrivateChat
: L10n.of(context)!.inviteGroupChat,
title: room.getLocalizedDisplayname(MatrixLocals(L10n.of(context)!)),
style: AdaptiveStyle.material,
actions: [
SheetAction(
key: InviteActions.accept,
label: L10n.of(context)!.accept,
icon: Icons.check_outlined,
isDefaultAction: true,
),
SheetAction(
key: InviteActions.decline,
label: L10n.of(context)!.decline,
icon: Icons.close_outlined,
isDestructiveAction: true,
),
SheetAction(
key: InviteActions.block,
label: L10n.of(context)!.block,
icon: Icons.block_outlined,
isDestructiveAction: true,
),
],
);
if (consent == OkCancelResult.cancel) {
if (inviteAction == null) return;
if (inviteAction == InviteActions.block) {
context.go('/rooms/settings/security/ignorelist', extra: inviterId);
return;
}
if (inviteAction == InviteActions.decline) {
await showFutureLoadingDialog(
context: context,
future: room.leave,
@ -381,3 +396,9 @@ class ChatListItem extends StatelessWidget {
);
}
}
enum InviteActions {
accept,
decline,
block,
}