courseISchoolPresentation function

CourseISchoolPresentation courseISchoolPresentation({
  1. required bool hasCache,
  2. required bool showNetworkGuide,
  3. required bool allowEarlyNetworkGuide,
  4. required AsyncValue<bool> refresh,
  5. required AsyncValue<void> availability,
})

Implementation

CourseISchoolPresentation courseISchoolPresentation({
  required bool hasCache,
  required bool showNetworkGuide,
  required bool allowEarlyNetworkGuide,
  required AsyncValue<bool> refresh,
  required AsyncValue<void> availability,
}) {
  final refreshSucceeded = refresh.value == true;
  if (hasCache) {
    return showNetworkGuide && !refreshSucceeded ? .guide : .content;
  }
  final availabilityFailed = availability.hasError && !availability.isLoading;
  final refreshFailed = refresh.hasError && !refresh.isLoading;
  if ((showNetworkGuide ||
          (availabilityFailed && (allowEarlyNetworkGuide || refreshFailed))) &&
      !refreshSucceeded) {
    return .guide;
  }
  if (refreshFailed && !availability.isLoading) {
    return .genericFailure;
  }
  return .loading;
}