blockUser method
- UserId id,
- BlocklistReason? reason
override
Implementation
@override
Future<void> blockUser(UserId id, BlocklistReason? reason) async {
Log.debug('blockUser($id, $reason)', '$runtimeType');
final RxUser? user = users[id];
final BlocklistRecord? record = user?.user.value.isBlocked;
if (user?.user.value.isBlocked == null) {
user?.user.value.isBlocked = BlocklistRecord(
userId: id,
reason: reason,
at: PreciseDateTime.now(),
);
user?.user.refresh();
}
try {
await _graphQlProvider.blockUser(id, reason);
} catch (_) {
if (user != null && user.user.value.isBlocked != record) {
user.user.value.isBlocked = record ?? user.user.value.isBlocked;
user.user.refresh();
}
rethrow;
}
}