21 lines
642 B
Dart
21 lines
642 B
Dart
|
|
import '../constants/app_constants.dart';
|
||
|
|
|
||
|
|
class RetryUtils {
|
||
|
|
static DateTime calculateNextRetry(int intentoActual) {
|
||
|
|
final delay = RetryDelays.getDelay(intentoActual);
|
||
|
|
return DateTime.now().add(delay);
|
||
|
|
}
|
||
|
|
|
||
|
|
static bool shouldRetry(int intentos) {
|
||
|
|
return intentos < AppConstants.maxReintentos;
|
||
|
|
}
|
||
|
|
|
||
|
|
static String formatTimeRemaining(DateTime nextRetry) {
|
||
|
|
final diff = nextRetry.difference(DateTime.now());
|
||
|
|
if (diff.isNegative) return 'Ahora';
|
||
|
|
if (diff.inHours > 0) return '${diff.inHours}h ${diff.inMinutes % 60}m';
|
||
|
|
if (diff.inMinutes > 0) return '${diff.inMinutes}m';
|
||
|
|
return '${diff.inSeconds}s';
|
||
|
|
}
|
||
|
|
}
|