fromEntityPlus static method

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

Implementation

static Future<FeedFrontModel?> fromEntityPlus(
    String documentID, FeedFrontEntity? 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 FeedFrontModel(
    documentID: documentID,
    appId: entity.appId ?? '',
    description: entity.description,
    feed: feedHolder,
    backgroundOverridePosts: await BackgroundModel.fromEntityPlus(
        entity.backgroundOverridePosts,
        appId: appId),
    backgroundOverrideProfile: await BackgroundModel.fromEntityPlus(
        entity.backgroundOverrideProfile,
        appId: appId),
    conditions: await StorageConditionsModel.fromEntityPlus(entity.conditions,
        appId: appId),
  );
}