fix timer

This commit is contained in:
otsmr 2025-06-06 10:22:25 +02:00
parent 73c831bf0f
commit 23ae553203

View file

@ -105,7 +105,7 @@ class ApiService {
reconnectionTimer ??= Timer(Duration(seconds: _reconnectionDelay), () { reconnectionTimer ??= Timer(Duration(seconds: _reconnectionDelay), () {
Log.info("starting with reconnection."); Log.info("starting with reconnection.");
reconnectionTimer = null; reconnectionTimer = null;
connect(); connect(force: true);
}); });
_reconnectionDelay += 5; _reconnectionDelay += 5;
} }
@ -126,6 +126,7 @@ class ApiService {
return false; return false;
} }
reconnectionTimer?.cancel(); reconnectionTimer?.cancel();
reconnectionTimer = null;
final user = await getUser(); final user = await getUser();
if (user != null && user.isDemoUser) { if (user != null && user.isDemoUser) {
globalCallbackConnectionState(true); globalCallbackConnectionState(true);
@ -137,6 +138,7 @@ class ApiService {
} }
// ensure that the connect function is not called again by the timer. // ensure that the connect function is not called again by the timer.
reconnectionTimer?.cancel(); reconnectionTimer?.cancel();
reconnectionTimer = null;
isAuthenticated = false; isAuthenticated = false;