From 7875fd0d5840a54d6576e76ea951255731b68817 Mon Sep 17 00:00:00 2001 From: stopflock Date: Tue, 19 Aug 2025 17:29:32 -0500 Subject: [PATCH] fix loading cameras from offline areas --- lib/widgets/camera_provider_with_cache.dart | 32 ++++++++++----------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/lib/widgets/camera_provider_with_cache.dart b/lib/widgets/camera_provider_with_cache.dart index 95ee58d..a3f8dd7 100644 --- a/lib/widgets/camera_provider_with_cache.dart +++ b/lib/widgets/camera_provider_with_cache.dart @@ -35,24 +35,22 @@ class CameraProviderWithCache extends ChangeNotifier { // Debounce rapid panning/zooming _debounceTimer?.cancel(); _debounceTimer = Timer(const Duration(milliseconds: 400), () async { - final isOffline = AppState.instance.offlineMode; - if (!isOffline) { - try { - final fresh = await MapDataProvider().getCameras( - bounds: bounds, - profiles: profiles, - uploadMode: uploadMode, - source: MapSource.remote, - ); - if (fresh.isNotEmpty) { - CameraCache.instance.addOrUpdate(fresh); - notifyListeners(); - } - } catch (e) { - debugPrint('[CameraProviderWithCache] Overpass fetch failed: $e'); - // Cache already holds whatever is available for the view + try { + // Use MapSource.auto to handle both offline and online modes appropriately + final fresh = await MapDataProvider().getCameras( + bounds: bounds, + profiles: profiles, + uploadMode: uploadMode, + source: MapSource.auto, + ); + if (fresh.isNotEmpty) { + CameraCache.instance.addOrUpdate(fresh); + notifyListeners(); } - } // else, only cache is used + } catch (e) { + debugPrint('[CameraProviderWithCache] Camera fetch failed: $e'); + // Cache already holds whatever is available for the view + } }); }