unblockUser method

  1. @override
Future<void> unblockUser(
  1. UserId id
)
override

Removes the specified User from the blocklist of the authenticated MyUser.

Implementation

@override
Future<void> unblockUser(UserId id) async {
  Log.debug('unblockUser($id)', '$runtimeType');

  final RxUser? user = users[id];
  final BlocklistRecord? record = user?.user.value.isBlocked;

  if (user?.user.value.isBlocked != null) {
    user?.user.value.isBlocked = null;
    user?.user.refresh();
  }

  try {
    await _graphQlProvider.unblockUser(id);
  } catch (_) {
    if (user != null && user.user.value.isBlocked != record) {
      user.user.value.isBlocked = record ?? user.user.value.isBlocked;
      user.user.refresh();
    }
    rethrow;
  }
}