refreshRelations static method

Future<ProductModel> refreshRelations(
  1. ProductModel model
)

Implementation

static Future<ProductModel> refreshRelations(ProductModel model) async {
  ShopModel? shopHolder;
  if (model.shop != null) {
    try {
      await shopRepository(appId: model.appId)!
          .get(model.shop!.documentID)
          .then((val) {
        shopHolder = val;
      }).catchError((error) {});
    } catch (_) {}
  }

  List<ProductImageModel>? imagesHolder;
  if (model.images != null) {
    imagesHolder = List<ProductImageModel>.from(
            await Future.wait(model.images!.map((element) async {
      return await ProductImageCache.refreshRelations(element);
    })))
        .toList();
  }

  return model.copyWith(
    shop: shopHolder,
    images: imagesHolder,
  );
}