refreshRelations static method

Future<PresentationModel> refreshRelations(
  1. PresentationModel model
)

Implementation

static Future<PresentationModel> refreshRelations(
    PresentationModel model) async {
  PlatformMediumModel? imageHolder;
  if (model.image != null) {
    try {
      await platformMediumRepository(appId: model.appId)!
          .get(model.image!.documentID)
          .then((val) {
        imageHolder = val;
      }).catchError((error) {});
    } catch (_) {}
  }

  List<BodyComponentModel>? bodyComponentsHolder;
  if (model.bodyComponents != null) {
    bodyComponentsHolder = List<BodyComponentModel>.from(
            await Future.wait(model.bodyComponents!.map((element) async {
      return await BodyComponentCache.refreshRelations(element);
    })))
        .toList();
  }

  return model.copyWith(
    image: imageHolder,
    bodyComponents: bodyComponentsHolder,
  );
}