From 89f8ad2e0ab8d32c9bdab0baf1fb473de42a4c2f Mon Sep 17 00:00:00 2001 From: stopflock Date: Thu, 4 Dec 2025 19:34:51 -0600 Subject: [PATCH] Clean up nav state when offline mode is enabled --- lib/app_state.dart | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/lib/app_state.dart b/lib/app_state.dart index 4b805c2..4be3acc 100644 --- a/lib/app_state.dart +++ b/lib/app_state.dart @@ -175,7 +175,22 @@ class AppState extends ChangeNotifier { bool get suspectedLocationsLoading => _suspectedLocationState.isLoading; DateTime? get suspectedLocationsLastFetch => _suspectedLocationState.lastFetchTime; + // Track previous offline mode to detect changes + bool? _previousOfflineMode; + void _onStateChanged() { + // Check if offline mode changed + final currentOfflineMode = _settingsState.offlineMode; + if (_previousOfflineMode != null && _previousOfflineMode != currentOfflineMode) { + // Offline mode changed + if (currentOfflineMode) { + // Went offline - cancel any active navigation/search + debugPrint('[AppState] Went offline - canceling navigation'); + _navigationState.cancelNavigation(); + } + } + _previousOfflineMode = currentOfflineMode; + notifyListeners(); } @@ -184,6 +199,9 @@ class AppState extends ChangeNotifier { // Initialize all state modules await _settingsState.init(); + // Initialize offline mode tracking + _previousOfflineMode = _settingsState.offlineMode; + // Initialize changelog service await ChangelogService().init();