updateFollowers method

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

adds notification.fromAtSign into followers list.

Implementation

Future<void> updateFollowers(AtNotification notification,
    {bool isSetStatus = true}) async {
  try {
    if (isSetStatus) connectionProvider.setStatus(Status.loading);
    var atKey = this._formKey();
    if (followers.list!.contains(notification.from)) {
      if (isSetStatus) connectionProvider.setStatus(Status.done);
      return;
    }
    followers.add(notification.from);
    await _sdkService.put(atKey, followers.toString());
    await _sdkService.sync();
    var atsignData = await _getAtsignData(
      notification.from,
      isNew: true,
    );
    connectionProvider.followersList!.add(atsignData);
    if (isSetStatus) {
      connectionProvider.setStatus(Status.done);
      await _sdkService.sync();
    }
  } catch (err) {
    connectionProvider.error = err;
    connectionProvider.setStatus(Status.error);
  }
}