fix(alarm): handle snooze reschedule failures instead of silently dropping them
posponerAlarma() and posponerProximaDesdePreaviso() called the native scheduler with no error handling, unlike guardarAlarma(). When the native call failed (e.g. revoked exact-alarm permission), the exception escaped before notifyListeners() ran, leaving the alarm list stuck on stale data with no real alarm scheduled and no snooze countdown notification. Both methods now mirror guardarAlarma()'s pattern: permission pre-check, try/catch into _error, and an unconditional notifyListeners() so the UI always reflects the outcome. Failures surface via SnackBar in the ringing screen and in app.dart's postpone-next handler.
This commit is contained in:
+7
-1
@@ -300,10 +300,16 @@ class _PaginaPrincipalState extends State<_PaginaPrincipal> {
|
||||
);
|
||||
if (!mounted) return;
|
||||
setState(() => _indice = 3);
|
||||
// posponerProximaDesdePreaviso no longer throws on a native scheduling
|
||||
// failure — it records the failure into EstadoAlarmas.error instead.
|
||||
// Branch on it here so the user sees the real outcome instead of an
|
||||
// always-success message.
|
||||
final error = estado.error;
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(
|
||||
AppLocalizations.of(context).alarmPostponedCurrentExecution,
|
||||
error ??
|
||||
AppLocalizations.of(context).alarmPostponedCurrentExecution,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user