Decky/app/src/lib/auto-refresh.ts
Elijah ee2ef03982
Some checks are pending
Validate Decky / web-client (push) Waiting to run
Add automatic background refresh
2026-07-20 09:00:29 -07:00

23 lines
614 B
TypeScript

export const AUTO_REFRESH_IDLE_MS = 10_000;
export const AUTO_REFRESH_REPEAT_MS = 30_000;
export interface AutoRefreshState {
now: number;
lastInteractionAt: number;
lastRefreshAt: number;
connected: boolean;
busy: boolean;
editing: boolean;
dragging: boolean;
visible: boolean;
}
export function shouldAutoRefresh(state: AutoRefreshState): boolean {
return state.connected
&& state.visible
&& !state.busy
&& !state.editing
&& !state.dragging
&& state.now - state.lastInteractionAt >= AUTO_REFRESH_IDLE_MS
&& state.now - state.lastRefreshAt >= AUTO_REFRESH_REPEAT_MS;
}