mirror of
https://github.com/Yubico/yubioath-flutter.git
synced 2024-11-22 00:12:09 +03:00
Only refresh OATH while page is active
This commit is contained in:
parent
56702f981b
commit
accbb3a3ee
@ -196,8 +196,11 @@ final desktopOathCredentialListProvider = StateNotifierProvider.autoDispose
|
|||||||
.select((r) => r.whenOrNull(data: (state) => state.locked) ?? true)),
|
.select((r) => r.whenOrNull(data: (state) => state.locked) ?? true)),
|
||||||
);
|
);
|
||||||
ref.listen<WindowState>(windowStateProvider, (_, windowState) {
|
ref.listen<WindowState>(windowStateProvider, (_, windowState) {
|
||||||
notifier._notifyWindowState(windowState);
|
notifier._rescheduleTimer(windowState.active);
|
||||||
}, fireImmediately: true);
|
}, fireImmediately: true);
|
||||||
|
ref.listen(currentSectionProvider, (_, section) {
|
||||||
|
notifier._rescheduleTimer(section == Section.accounts);
|
||||||
|
});
|
||||||
|
|
||||||
return notifier;
|
return notifier;
|
||||||
},
|
},
|
||||||
@ -231,9 +234,9 @@ class DesktopCredentialListNotifier extends OathCredentialListNotifier {
|
|||||||
DesktopCredentialListNotifier(this._withContext, this._session, this._locked)
|
DesktopCredentialListNotifier(this._withContext, this._session, this._locked)
|
||||||
: super();
|
: super();
|
||||||
|
|
||||||
void _notifyWindowState(WindowState windowState) {
|
void _rescheduleTimer(bool active) {
|
||||||
if (_locked) return;
|
if (_locked) return;
|
||||||
if (windowState.active) {
|
if (active) {
|
||||||
_scheduleRefresh();
|
_scheduleRefresh();
|
||||||
} else {
|
} else {
|
||||||
_timer?.cancel();
|
_timer?.cancel();
|
||||||
|
Loading…
Reference in New Issue
Block a user