fix(app): refresh visible lists on foreground resume
This commit is contained in:
@@ -80,6 +80,10 @@ class _PipelinesAppState extends State<PipelinesApp>
|
||||
/// list once; the run itself is then opened from its route.
|
||||
int _runsRefresh = 0;
|
||||
|
||||
/// Prevents duplicate resumed notifications from refreshing twice before
|
||||
/// the next background transition starts another foreground visit.
|
||||
bool _foregroundVisitHandled = false;
|
||||
|
||||
/// One run detail request from Search, delivered through the shell so the
|
||||
/// mounted run detail can resolve it once the named run's steps have loaded.
|
||||
/// A field or artifact hit names no addressable URL of its own, so the request
|
||||
@@ -198,9 +202,29 @@ class _PipelinesAppState extends State<PipelinesApp>
|
||||
/// facts), so no screen re-subscribes on its own.
|
||||
@override
|
||||
void didChangeAppLifecycleState(AppLifecycleState state) {
|
||||
if (state != AppLifecycleState.resumed) return;
|
||||
if (!shouldReconnectOnForeground(_session.connection.kind)) return;
|
||||
unawaited(_session.retry());
|
||||
if (state != AppLifecycleState.resumed) {
|
||||
_foregroundVisitHandled = false;
|
||||
return;
|
||||
}
|
||||
if (_foregroundVisitHandled) return;
|
||||
_foregroundVisitHandled = true;
|
||||
final connection = _session.connection.kind;
|
||||
if (shouldReconnectOnForeground(connection)) {
|
||||
unawaited(_session.retry());
|
||||
return;
|
||||
}
|
||||
if (connection != ConnectionKind.connected) return;
|
||||
|
||||
// A return to the foreground refreshes only the visible list. Detail routes
|
||||
// (including pipeline definitions and run visits) keep their current data.
|
||||
final route = _delegate.route;
|
||||
if (route.kind == AppRouteKind.pipelines &&
|
||||
route.pipelineId == null &&
|
||||
route.stageKey == null) {
|
||||
setState(() => _pipelinesRefresh++);
|
||||
} else if (route.kind == AppRouteKind.runs && route.runId == null) {
|
||||
setState(() => _runsRefresh++);
|
||||
}
|
||||
}
|
||||
|
||||
/// A replaced socket drops the attention status baseline so the gap cannot
|
||||
|
||||
Reference in New Issue
Block a user