fix(app): re-check connectivity on foreground resume to clear false-offline banner

When backgrounded, the periodic TCP ping times out causing isOnline=false.
On resume, immediately re-check so the banner clears as soon as the app
is foregrounded rather than waiting up to 30s for the next scheduled check.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
hailin 2026-03-06 08:08:01 -08:00
parent 947a47869e
commit 0aac693b5d
1 changed files with 3 additions and 0 deletions

View File

@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import '../updater/update_service.dart';
import '../network/connectivity_provider.dart';
import '../widgets/offline_banner.dart';
import '../../features/auth/data/providers/auth_provider.dart';
import '../../features/auth/presentation/pages/login_page.dart';
@ -120,6 +121,8 @@ class _ScaffoldWithNavState extends ConsumerState<ScaffoldWithNav>
@override
void didChangeAppLifecycleState(AppLifecycleState state) {
if (state == AppLifecycleState.resumed) {
// Re-check connectivity immediately on foreground to clear false-offline banner
ref.read(connectivityProvider.notifier).check();
_checkForUpdateIfNeeded();
}
}