Clear node cache when switching to/from sandbox

This commit is contained in:
stopflock committed 2025-09-28 23:16:01 -05:00
1 parent 363439f712
commit 9bf46721f0
2 files changed
+8 -1

No files matched your search

+7
View File
@@ -8,6 +8,8 @@ import 'models/osm_camera_node.dart';
import 'models/pending_upload.dart'; import 'models/pending_upload.dart';
import 'models/tile_provider.dart'; import 'models/tile_provider.dart';
import 'services/offline_area_service.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/auth_state.dart';
import 'state/operator_profile_state.dart'; import 'state/operator_profile_state.dart';
import 'state/profile_state.dart'; import 'state/profile_state.dart';
@@ -238,6 +240,11 @@ class AppState extends ChangeNotifier {
} }
Future<void> setUploadMode(UploadMode mode) async { Future<void> 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 _settingsState.setUploadMode(mode);
await _authState.onUploadModeChanged(mode); await _authState.onUploadModeChanged(mode);
_startUploader(); // Restart uploader with new mode _startUploader(); // Restart uploader with new mode
+1 -1
View File
@@ -158,7 +158,7 @@ class MapViewState extends State<MapView> {
ScaffoldMessenger.of(context).showSnackBar( ScaffoldMessenger.of(context).showSnackBar(
SnackBar( SnackBar(
content: Text(message), content: Text(message),
duration: const Duration(seconds: 2), duration: const Duration(seconds: 4),
behavior: SnackBarBehavior.floating, behavior: SnackBarBehavior.floating,
), ),
); );