Clean up nav state when offline mode is enabled

This commit is contained in:
stopflock
2025-12-04 19:34:51 -06:00
parent cc1a335a49
commit 89f8ad2e0a

View File

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