From accbb3a3ee7331965ce7c89c558744be65d434f9 Mon Sep 17 00:00:00 2001 From: Dain Nilsson Date: Wed, 11 Sep 2024 12:39:22 +0200 Subject: [PATCH] Only refresh OATH while page is active --- lib/desktop/oath/state.dart | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/desktop/oath/state.dart b/lib/desktop/oath/state.dart index cdd133f7..c0434613 100755 --- a/lib/desktop/oath/state.dart +++ b/lib/desktop/oath/state.dart @@ -196,8 +196,11 @@ final desktopOathCredentialListProvider = StateNotifierProvider.autoDispose .select((r) => r.whenOrNull(data: (state) => state.locked) ?? true)), ); ref.listen(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();