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", "joinSpace": "Join space",
"publicSpaces": "Public spaces", "publicSpaces": "Public spaces",
"addChatOrSubSpace": "Add chat or sub space", "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) { if (room.membership == Membership.invite) {
final inviterId = final inviterId =
room.getState(EventTypes.RoomMember, room.client.userID!)?.senderId; room.getState(EventTypes.RoomMember, room.client.userID!)?.senderId;
final profile = inviterId == null final inviteAction = await showModalActionSheet<InviteActions>(
? null
: await showFutureLoadingDialog(
context: context,
future: () => room.client.getProfileFromUserId(inviterId),
);
final consent = await showOkCancelAlertDialog(
context: context, context: context,
title: L10n.of(context)!.inviteForMe, message: room.isDirectChat
message: L10n.of(context)!.youInvitedBy( ? L10n.of(context)!.invitePrivateChat
profile?.result?.displayName ?? : L10n.of(context)!.inviteGroupChat,
profile?.result?.userId.localpart ?? title: room.getLocalizedDisplayname(MatrixLocals(L10n.of(context)!)),
L10n.of(context)!.user, style: AdaptiveStyle.material,
), actions: [
okLabel: L10n.of(context)!.joinRoom, SheetAction(
cancelLabel: L10n.of(context)!.delete, key: InviteActions.accept,
barrierDismissible: false, 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( await showFutureLoadingDialog(
context: context, context: context,
future: room.leave, future: room.leave,
@ -381,3 +396,9 @@ class ChatListItem extends StatelessWidget {
); );
} }
} }
enum InviteActions {
accept,
decline,
block,
}