refreshRelations static method

Future<SectionModel> refreshRelations(
  1. SectionModel model
)

Implementation

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

  List<LinkModel>? linksHolder;
  if (model.links != null) {
    linksHolder = List<LinkModel>.from(
            await Future.wait(model.links!.map((element) async {
      return await LinkCache.refreshRelations(element);
    })))
        .toList();
  }

  return model.copyWith(
    image: imageHolder,
    links: linksHolder,
  );
}