From c1e25ec5b185561a1013f4a6d8a650983f67ded5 Mon Sep 17 00:00:00 2001 From: stopflock Date: Tue, 26 Aug 2025 18:35:52 -0500 Subject: [PATCH] improve network status indicator --- lib/services/network_status.dart | 18 ++++++------------ lib/services/simple_tile_service.dart | 7 +++++-- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/lib/services/network_status.dart b/lib/services/network_status.dart index 0680a2c..2f5ea23 100644 --- a/lib/services/network_status.dart +++ b/lib/services/network_status.dart @@ -112,20 +112,12 @@ class NetworkStatus extends ChangeNotifier { // Don't log routine waiting - only log if we stay waiting too long } - // Set timeout to show appropriate status after reasonable time + // Set timeout for genuine network issues (not 404s) _waitingTimer?.cancel(); - _waitingTimer = Timer(const Duration(seconds: 10), () { + _waitingTimer = Timer(const Duration(seconds: 8), () { _isWaitingForData = false; - - // If in offline mode, this is "no data" not "timed out" - if (AppState.instance.offlineMode) { - _hasNoData = true; - debugPrint('[NetworkStatus] No offline data available (timeout in offline mode)'); - } else { - _isTimedOut = true; - debugPrint('[NetworkStatus] Data request timed out (online mode)'); - } - + _isTimedOut = true; + debugPrint('[NetworkStatus] Request timed out - likely network issues'); notifyListeners(); }); } @@ -143,6 +135,8 @@ class NetworkStatus extends ChangeNotifier { // Quietly clear waiting status - don't log routine data arrival } } + + /// Report that a tile was not available offline void reportOfflineMiss() { diff --git a/lib/services/simple_tile_service.dart b/lib/services/simple_tile_service.dart index 222f537..d297046 100644 --- a/lib/services/simple_tile_service.dart +++ b/lib/services/simple_tile_service.dart @@ -71,8 +71,11 @@ class SimpleTileHttpClient extends http.BaseClient { } catch (e) { debugPrint('[SimpleTileService] Could not get tile $z/$x/$y: $e'); - // Let MapDataProvider handle offline mode logic - // Just return 404 and let flutter_map handle it gracefully + // 404 means no tiles available - clear waiting status + // This is true whether we're online or offline + NetworkStatus.instance.clearWaiting(); + + // Return 404 and let flutter_map handle it gracefully return http.StreamedResponse( Stream.value([]), 404,