Home Screen: Inform on connection lose
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user