Only refresh OATH while page is active

This commit is contained in:
Dain Nilsson 2024-09-11 12:39:22 +02:00
parent 56702f981b
commit accbb3a3ee
No known key found for this signature in database
GPG Key ID: F04367096FBA95E8

View File

@ -196,8 +196,11 @@ final desktopOathCredentialListProvider = StateNotifierProvider.autoDispose
.select((r) => r.whenOrNull(data: (state) => state.locked) ?? true)),
);
ref.listen<WindowState>(windowStateProvider, (_, windowState) {
notifier._notifyWindowState(windowState);
notifier._rescheduleTimer(windowState.active);
}, fireImmediately: true);
ref.listen(currentSectionProvider, (_, section) {
notifier._rescheduleTimer(section == Section.accounts);
});
return notifier;
},
@ -231,9 +234,9 @@ class DesktopCredentialListNotifier extends OathCredentialListNotifier {
DesktopCredentialListNotifier(this._withContext, this._session, this._locked)
: super();
void _notifyWindowState(WindowState windowState) {
void _rescheduleTimer(bool active) {
if (_locked) return;
if (windowState.active) {
if (active) {
_scheduleRefresh();
} else {
_timer?.cancel();