Home Screen: Inform on connection lose

This commit is contained in:
2026-03-24 21:58:42 +01:00
parent b4ff5884b9
commit 400dee57d4
2 changed files with 34 additions and 14 deletions
+9 -1
View File
@@ -149,6 +149,11 @@ final colorProvider = StateNotifierProvider<ColorNotifier, BusylightColor>(
},
);
// ── Connection lost indicator ─────────────────────────────────────────────────
// Set to true by the polling notifier when a poll fails, false on success.
final connectionLostProvider = StateProvider<bool>((_) => false);
// ── Background polling ────────────────────────────────────────────────────────
// Periodically pulls status + color from the device and silently updates state.
@@ -181,8 +186,11 @@ class PollingNotifier extends StateNotifier<void> {
_ref.read(busylightStatusProvider.notifier).setLocalStatus(status);
_ref.read(colorProvider.notifier).silentSet(color);
_ref.read(brightnessProvider.notifier).silentSet(color.brightness);
// Connection restored — clear the lost flag
_ref.read(connectionLostProvider.notifier).state = false;
} catch (_) {
// Silently ignore poll errors — connection issues are shown on manual refresh
// Signal connectivity issue to the UI
_ref.read(connectionLostProvider.notifier).state = true;
}
}