fromEntityPlus static method

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

Implementation

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

  FeedModel? feedHolder;
  if (entity.feedId != null) {
    try {
      feedHolder = await feedRepository(appId: appId)!.get(entity.feedId);
    } on Exception catch (e) {
      print('Error whilst trying to initialise feed');
      print('Error whilst retrieving feed with id ${entity.feedId}');
      print('Exception: $e');
    }
  }

  return ProfileModel(
    documentID: documentID,
    appId: entity.appId ?? '',
    description: entity.description,
    feed: feedHolder,
    backgroundOverride: await BackgroundModel.fromEntityPlus(
        entity.backgroundOverride,
        appId: appId),
    conditions: await StorageConditionsModel.fromEntityPlus(entity.conditions,
        appId: appId),
  );
}