From 32507e1646ddc2ac94ca376a5bc9cad842946ba7 Mon Sep 17 00:00:00 2001 From: stopflock Date: Thu, 21 Aug 2025 19:20:45 -0500 Subject: [PATCH] fix offlines cameras loading on zoom out --- lib/state/auth_state.dart | 37 ------------------------------------- lib/widgets/map_view.dart | 5 +++-- 2 files changed, 3 insertions(+), 39 deletions(-) diff --git a/lib/state/auth_state.dart b/lib/state/auth_state.dart index 076c260..201a714 100644 --- a/lib/state/auth_state.dart +++ b/lib/state/auth_state.dart @@ -18,15 +18,7 @@ class AuthState extends ChangeNotifier { try { if (await _auth.isLoggedIn()) { - print('AuthState: User appears to be logged in, fetching username...'); _username = await _auth.login(); - if (_username != null) { - print("AuthState: Successfully retrieved username: $_username"); - } else { - print('AuthState: Failed to retrieve username despite being logged in'); - } - } else { - print('AuthState: User is not logged in'); } } catch (e) { print("AuthState: Error during auth initialization: $e"); @@ -35,13 +27,7 @@ class AuthState extends ChangeNotifier { Future login() async { try { - print('AuthState: Starting login process...'); _username = await _auth.login(); - if (_username != null) { - print("AuthState: Login successful for user: $_username"); - } else { - print('AuthState: Login failed - no username returned'); - } } catch (e) { print("AuthState: Login error: $e"); _username = null; @@ -57,17 +43,9 @@ class AuthState extends ChangeNotifier { Future refreshAuthState() async { try { - print('AuthState: Refreshing auth state...'); if (await _auth.isLoggedIn()) { - print('AuthState: Token exists, fetching username...'); _username = await _auth.login(); - if (_username != null) { - print("AuthState: Auth refresh successful: $_username"); - } else { - print('AuthState: Auth refresh failed - no username'); - } } else { - print('AuthState: No valid token found'); _username = null; } } catch (e) { @@ -79,13 +57,7 @@ class AuthState extends ChangeNotifier { Future forceLogin() async { try { - print('AuthState: Starting forced fresh login...'); _username = await _auth.forceLogin(); - if (_username != null) { - print("AuthState: Forced login successful: $_username"); - } else { - print('AuthState: Forced login failed - no username returned'); - } } catch (e) { print("AuthState: Forced login error: $e"); _username = null; @@ -109,23 +81,14 @@ class AuthState extends ChangeNotifier { // Refresh user display for active mode, validating token try { if (await _auth.isLoggedIn()) { - print('AuthState: Switching mode, token exists; validating...'); final isValid = await validateToken(); if (isValid) { - print("AuthState: Switching mode; fetching username for $mode..."); _username = await _auth.login(); - if (_username != null) { - print("AuthState: Switched mode, now logged in as $_username"); - } else { - print('AuthState: Switched mode but failed to retrieve username'); - } } else { - print('AuthState: Switching mode, token invalid—auto-logout.'); await logout(); // This clears _username also. } } else { _username = null; - print("AuthState: Mode change: not logged in in $mode"); } } catch (e) { _username = null; diff --git a/lib/widgets/map_view.dart b/lib/widgets/map_view.dart index 0c58a01..efd9d38 100644 --- a/lib/widgets/map_view.dart +++ b/lib/widgets/map_view.dart @@ -207,8 +207,9 @@ class _MapViewState extends State { if (session != null) { appState.updateSession(target: pos.center); } - // Only request more cameras if the user navigated the map (and at valid zoom) - if (gesture && pos.zoom >= 10) { + // Request more cameras on any map movement/zoom at valid zoom level + // This ensures cameras load even when zooming without panning (like with zoom buttons) + if (pos.zoom >= 10) { _debounce(_refreshCamerasFromProvider); } },