fromEntityPlus static method

Future<FollowingModel?> fromEntityPlus(
  1. String documentID,
  2. FollowingEntity? entity, {
  3. String? appId,
})

Implementation

static Future<FollowingModel?> fromEntityPlus(
    String documentID, FollowingEntity? entity,
    {String? appId}) async {
  if (entity == null) return null;

  MemberPublicInfoModel? followerHolder;
  if (entity.followerId != null) {
    try {
      followerHolder = await memberPublicInfoRepository(appId: appId)!
          .get(entity.followerId);
    } on Exception catch (e) {
      print('Error whilst trying to initialise follower');
      print(
          'Error whilst retrieving memberPublicInfo with id ${entity.followerId}');
      print('Exception: $e');
    }
  }

  MemberPublicInfoModel? followedHolder;
  if (entity.followedId != null) {
    try {
      followedHolder = await memberPublicInfoRepository(appId: appId)!
          .get(entity.followedId);
    } on Exception catch (e) {
      print('Error whilst trying to initialise followed');
      print(
          'Error whilst retrieving memberPublicInfo with id ${entity.followedId}');
      print('Exception: $e');
    }
  }

  return FollowingModel(
    documentID: documentID,
    appId: entity.appId ?? '',
    follower: followerHolder,
    followed: followedHolder,
  );
}