Skip to content

Commit

Permalink
Only refresh OATH while page is active
Browse files Browse the repository at this point in the history
  • Loading branch information
dainnilsson committed Sep 11, 2024
1 parent 56702f9 commit accbb3a
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions lib/desktop/oath/state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;
},
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit accbb3a

Please sign in to comment.