mirror of
https://github.com/krille-chan/fluffychat
synced 2024-09-17 09:35:12 +00:00
feat: Block users who sent invites
This commit is contained in:
parent
b71023954d
commit
991277d5f5
2 changed files with 40 additions and 18 deletions
|
@ -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"
|
||||||
}
|
}
|
|
@ -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,
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue