fix(alarmas): reload and re-sync alarms after backup import
Importing a backup wrote the alarm/vacation/exception block straight to SharedPreferences but never told EstadoAlarmas about it, so the UI kept showing the pre-import alarms, a later edit could persist that stale state back over the imported one, and imported alarms were never (re)scheduled with the Android native layer. The backup screen now calls EstadoAlarmas.cargarPersistidasSinRecalcular() followed by refrescarProgramacion() after a successful import, extracted into a directly-testable aplicarImportacionConfig() function.
This commit is contained in:
@@ -945,7 +945,12 @@ class EstadoRadio extends ChangeNotifier {
|
||||
final alarmasData = data['alarmas'];
|
||||
if (alarmasData is Map<String, dynamic>) {
|
||||
// Escribimos el bloque JSON tal como estaba en el dispositivo origen.
|
||||
// ServicioAlarmas lo leerá con su propio fromJson al siguiente acceso.
|
||||
// EstadoAlarmas es un ChangeNotifier independiente y de larga vida
|
||||
// que ya cargó sus alarmas en memoria: NO relee este storage por sí
|
||||
// solo. El llamador (pantalla_ajustes_backup.dart) es responsable de
|
||||
// invocar `EstadoAlarmas.cargarPersistidasSinRecalcular()` seguido
|
||||
// de `refrescarProgramacion()` tras un import exitoso; EstadoRadio
|
||||
// se mantiene deliberadamente sin depender de EstadoAlarmas.
|
||||
await prefs.setString(_keyAlarmasConfig, jsonEncode(alarmasData));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user