mirror of
https://github.com/Yubico/yubioath-flutter.git
synced 2024-11-25 23:14:18 +03:00
add refresh debug logs
This commit is contained in:
parent
bddf5d9074
commit
8e7344f6a3
@ -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);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user