chore: Leave invites and DM rooms when blocking a user

This commit is contained in:
Christian Kußowski 2025-09-19 10:00:18 +02:00
parent 21a1ceb19e
commit 1ea8664c48
No known key found for this signature in database
GPG key ID: E067ECD60F1A0652

View file

@ -43,9 +43,25 @@ class SettingsIgnoreListController extends State<SettingsIgnoreList> {
errorText = null;
});
final client = Matrix.of(context).client;
showFutureLoadingDialog(
context: context,
future: () => Matrix.of(context).client.ignoreUser(userId),
future: () async {
for (final room in client.rooms) {
final isInviteFromUser = room.membership == Membership.invite &&
room.getState(EventTypes.RoomMember, client.userID!)?.senderId ==
userId;
if (room.directChatMatrixID == userId || isInviteFromUser) {
try {
await room.leave();
} catch (e, s) {
Logs().w('Unable to leave room with blocked user $userId', e, s);
}
}
}
await client.ignoreUser(userId);
},
);
setState(() {});
controller.clear();