mirror of
https://github.com/rzuasti/oott.git
synced 2026-07-08 19:21:54 +02:00
Pause polling and show a banner when the backend is unreachable
Adds a centralized BackendReachability singleton fed by a Dio interceptor (connection-level failures only) and connectivity_plus. PolledValue subscribes to it and pauses on offline / reloads immediately on reconnect, replacing the previous per-card error cascade. MainShell renders a global OfflineBanner with Retry and Settings actions; cards downgrade error→stale when offline so the banner is the only red element. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
8be65f3ffa
commit
b5da90be59
@@ -4,6 +4,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
|
||||
import '../model/arp_scanner_status.dart';
|
||||
import '../utils/backend_reachability.dart';
|
||||
import '../utils/duration_formatter.dart';
|
||||
import '../utils/oott_api.dart';
|
||||
import '../utils/polled_value.dart';
|
||||
@@ -44,9 +45,10 @@ class _ArpScannerCardState extends State<ArpScannerCard> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ListenableBuilder(
|
||||
listenable: _polled,
|
||||
listenable: Listenable.merge([_polled, BackendReachability.instance]),
|
||||
builder: (context, _) {
|
||||
if (_polled.freshness == PolledFreshness.initialLoading) {
|
||||
final freshness = effectiveFreshness(_polled);
|
||||
if (freshness == PolledFreshness.initialLoading) {
|
||||
return const Card(
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(16),
|
||||
@@ -55,8 +57,8 @@ class _ArpScannerCardState extends State<ArpScannerCard> {
|
||||
);
|
||||
}
|
||||
|
||||
final (color, label, sublabel) = _resolveState();
|
||||
final isStale = _polled.freshness == PolledFreshness.stale;
|
||||
final (color, label, sublabel) = _resolveState(freshness);
|
||||
final isStale = freshness == PolledFreshness.stale;
|
||||
|
||||
return Card(
|
||||
clipBehavior: Clip.antiAlias,
|
||||
@@ -111,8 +113,8 @@ class _ArpScannerCardState extends State<ArpScannerCard> {
|
||||
);
|
||||
}
|
||||
|
||||
(Color, String, String?) _resolveState() {
|
||||
if (_polled.freshness == PolledFreshness.error) {
|
||||
(Color, String, String?) _resolveState(PolledFreshness freshness) {
|
||||
if (freshness == PolledFreshness.error) {
|
||||
return (
|
||||
Colors.red,
|
||||
'Error',
|
||||
|
||||
Reference in New Issue
Block a user