checkAfterApiFailure method

void checkAfterApiFailure(
  1. String serverUrl, {
  2. bool force = false,
})

Starts a non-blocking check after an eligible API failure.

Implementation

void checkAfterApiFailure(String serverUrl, {bool force = false}) {
  if (!LikeConstants.automaticConnectivityChecksEnabled) return;
  final origin = canonicalOrigin(serverUrl);
  if (origin == null) return;
  final now = _clock();
  final last = _lastAutomaticChecks[origin];
  if (!force &&
      last != null &&
      now.difference(last) < LikeConstants.automaticFailureCheckCooldown) {
    return;
  }
  _lastAutomaticChecks[origin] = now;
  unawaited(
    _runBackgroundCheck(
      serverUrl: serverUrl,
      reason: LikeConnectivityCheckReason.apiFailure,
      forceNewFlight: force,
    ),
  );
}