fix offlines cameras loading on zoom out

This commit is contained in:
stopflock
2025-08-21 19:20:45 -05:00
parent 1272eb9409
commit 32507e1646
2 changed files with 3 additions and 39 deletions

View File

@@ -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<void> 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<void> 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<void> 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;

View File

@@ -207,8 +207,9 @@ class _MapViewState extends State<MapView> {
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);
}
},