Files
faceclaw/app/util/render-freshness.ts
James Babcock 3532b1f437 Compatibility check; notification icon fixes
* Display a warning if paired glasses do not have a compatible custo firmware
 * Fix certain notification icons being missing on system card
 * Rescale large notification icons with proper sampling; don't send unnecessary
2026-07-04 14:27:25 -07:00

38 lines
1.2 KiB
TypeScript

/**
* Per-render-pass channel for stale-data tracking. JS is single-threaded and
* paints are synchronous, so module state set around a paint is visible to
* every data source consulted during it, without threading flags through each
* paint signature.
*
* Data sources with a cache (e.g. notification icons) consult
* renderPassAllowsStaleData() to decide whether to return expired cached data
* immediately instead of blocking the paint on a refetch, and report having
* done so via noteStaleDataUsed(). The render loop reads the result from
* endRenderPass() and schedules one follow-up repaint with fresh data, so the
* first frame out of sleep is never blocked on slow data sources.
*/
let allowStale = true;
let staleDataUsed = false;
export function beginRenderPass(allowStaleData: boolean): void {
allowStale = allowStaleData;
staleDataUsed = false;
}
export function renderPassAllowsStaleData(): boolean {
return allowStale;
}
export function noteStaleDataUsed(): void {
staleDataUsed = true;
}
/** End the pass, returning whether any source served stale data. */
export function endRenderPass(): boolean {
const usedStale = staleDataUsed;
allowStale = true;
staleDataUsed = false;
return usedStale;
}