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
@@ -2,6 +2,7 @@ import 'dart:async';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../utils/backend_reachability.dart';
|
||||
import '../utils/duration_formatter.dart';
|
||||
import '../utils/polled_value.dart';
|
||||
|
||||
@@ -39,9 +40,15 @@ class _PolledStaleIndicatorState extends State<PolledStaleIndicator> {
|
||||
DateTime.now().difference(lastSuccessAt).inSeconds.toDouble(),
|
||||
)
|
||||
: 'a while';
|
||||
final message = widget.polled.lastErrorMessage != null
|
||||
? 'Last updated $ago ago — ${widget.polled.lastErrorMessage}'
|
||||
: 'Last updated $ago ago';
|
||||
final isOffline = !BackendReachability.instance.isOnline;
|
||||
final String message;
|
||||
if (isOffline) {
|
||||
message = 'Offline — last updated $ago ago';
|
||||
} else if (widget.polled.lastErrorMessage != null) {
|
||||
message = 'Last updated $ago ago — ${widget.polled.lastErrorMessage}';
|
||||
} else {
|
||||
message = 'Last updated $ago ago';
|
||||
}
|
||||
return Tooltip(
|
||||
message: message,
|
||||
child: Icon(
|
||||
|
||||
Reference in New Issue
Block a user