From 9bf46721f058ca5217b82852eab8eff7035c99ce Mon Sep 17 00:00:00 2001 From: stopflock Date: Sun, 28 Sep 2025 23:16:01 -0500 Subject: [PATCH] Clear node cache when switching to/from sandbox --- lib/app_state.dart | 7 +++++++ lib/widgets/map_view.dart | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/app_state.dart b/lib/app_state.dart index cec1b47..16765ae 100644 --- a/lib/app_state.dart +++ b/lib/app_state.dart @@ -8,6 +8,8 @@ import 'models/osm_camera_node.dart'; import 'models/pending_upload.dart'; import 'models/tile_provider.dart'; import 'services/offline_area_service.dart'; +import 'services/node_cache.dart'; +import 'widgets/camera_provider_with_cache.dart'; import 'state/auth_state.dart'; import 'state/operator_profile_state.dart'; import 'state/profile_state.dart'; @@ -238,6 +240,11 @@ class AppState extends ChangeNotifier { } Future setUploadMode(UploadMode mode) async { + // Clear node cache when switching upload modes to prevent mixing production/sandbox data + NodeCache.instance.clear(); + CameraProviderWithCache.instance.notifyListeners(); + debugPrint('[AppState] Cleared node cache due to upload mode change'); + await _settingsState.setUploadMode(mode); await _authState.onUploadModeChanged(mode); _startUploader(); // Restart uploader with new mode diff --git a/lib/widgets/map_view.dart b/lib/widgets/map_view.dart index a9d67b2..36e81c3 100644 --- a/lib/widgets/map_view.dart +++ b/lib/widgets/map_view.dart @@ -158,7 +158,7 @@ class MapViewState extends State { ScaffoldMessenger.of(context).showSnackBar( SnackBar( content: Text(message), - duration: const Duration(seconds: 2), + duration: const Duration(seconds: 4), behavior: SnackBarBehavior.floating, ), );