add refresh debug logs

This commit is contained in:
Adam Velebil 2022-05-12 14:04:26 +02:00
parent bddf5d9074
commit 8e7344f6a3
No known key found for this signature in database
GPG Key ID: AC6D6B9D715FC084

View File

@ -259,6 +259,7 @@ class _AndroidCredentialListNotifier extends OathCredentialListNotifier {
_timer?.cancel();
if (_currentDevice == null) return;
if (state == null) {
_log.debug('No OATH state, refresh immediately');
refresh();
} else if (mounted) {
final expirations = (state ?? [])
@ -269,13 +270,16 @@ class _AndroidCredentialListNotifier extends OathCredentialListNotifier {
.whereType<OathCode>()
.map((e) => e.validTo);
if (expirations.isEmpty) {
_log.debug('No expirations, no refresh');
_timer = null;
} else {
final earliest = expirations.reduce(min) * 1000;
final now = DateTime.now().millisecondsSinceEpoch;
if (earliest < now) {
_log.debug('Already expired, refresh immediately');
refresh();
} else {
_log.debug('Schedule refresh in ${earliest - now}ms');
_timer = Timer(Duration(milliseconds: earliest - now), refresh);
}
}