refreshRelations static method

Future<OrderModel> refreshRelations(
  1. OrderModel model
)

Implementation

static Future<OrderModel> refreshRelations(OrderModel model) async {
  MemberModel? customerHolder;
  if (model.customer != null) {
    try {
      await memberRepository(appId: model.appId)!
          .get(model.customer!.documentID)
          .then((val) {
        customerHolder = val;
      }).catchError((error) {});
    } catch (_) {}
  }

  List<OrderItemModel>? productsHolder;
  if (model.products != null) {
    productsHolder = List<OrderItemModel>.from(
            await Future.wait(model.products!.map((element) async {
      return await OrderItemCache.refreshRelations(element);
    })))
        .toList();
  }

  return model.copyWith(
    customer: customerHolder,
    products: productsHolder,
  );
}