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();