refreshRelations static method

Future<MemberModel> refreshRelations(
  1. MemberModel model
)

Implementation

static Future<MemberModel> refreshRelations(MemberModel model) async {
  PublicMediumModel? photoHolder;
  if (model.photo != null) {
    try {
      await publicMediumRepository()!
          .get(model.photo!.documentID)
          .then((val) {
        photoHolder = val;
      }).catchError((error) {});
    } catch (_) {}
  }

  List<MemberSubscriptionModel>? subscriptionsHolder;
  if (model.subscriptions != null) {
    subscriptionsHolder = List<MemberSubscriptionModel>.from(
            await Future.wait(model.subscriptions!.map((element) async {
      return await MemberSubscriptionCache.refreshRelations(element);
    })))
        .toList();
  }

  return model.copyWith(
    photo: photoHolder,
    subscriptions: subscriptionsHolder,
  );
}