Add automatic background refresh
Some checks are pending
Validate Decky / web-client (push) Waiting to run
Some checks are pending
Validate Decky / web-client (push) Waiting to run
This commit is contained in:
parent
e9d76cc4a2
commit
ee2ef03982
9 changed files with 163 additions and 25 deletions
23
app/src/lib/auto-refresh.ts
Normal file
23
app/src/lib/auto-refresh.ts
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
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;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue