deleteFollowers method

Future<void> deleteFollowers(
  1. AtNotification notification, {
  2. bool isSetStatus = true,
})

deletes notification.fromAtSign from followers list.

Implementation

Future<void> deleteFollowers(AtNotification notification,
    {bool isSetStatus = true}) async {
  try {
    if (isSetStatus) connectionProvider.setStatus(Status.loading);
    if (!followers.list!.contains(notification.from)) {
      if (isSetStatus) connectionProvider.setStatus(Status.done);
      return;
    }
    followers.remove(notification.from);
    var atKey = this._formKey();
    followers.list!.isNotEmpty
        ? await _sdkService.put(atKey, followers.toString())
        : await this._sdkService.put(atKey, 'null');

    connectionProvider.followersList!
        .removeWhere((element) => element.title == notification.from);
    if (isSetStatus) {
      connectionProvider.setStatus(Status.done);
      await _sdkService.sync();
    }
  } catch (err) {
    connectionProvider.error = err;
    connectionProvider.setStatus(Status.error);
  }
}