chore: Leave invites and DM rooms when blocking a user
This commit is contained in:
parent
21a1ceb19e
commit
1ea8664c48
1 changed files with 17 additions and 1 deletions
|
|
@ -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();
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue