fromEntityPlus static method

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

Implementation

static Future<FollowRequestModel?> fromEntityPlus(
    String documentID, FollowRequestEntity? 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 FollowRequestModel(
    documentID: documentID,
    appId: entity.appId ?? '',
    follower: followerHolder,
    followed: followedHolder,
    status: toFollowRequestStatus(entity.status),
  );
}