treefmt: apply prettier
Pure `nix fmt` output from the commit before this one — no hand edits. 203 files: 52 md, 42 tsx, 32 js, 32 css, 21 ts, 13 html, 8 json, 3 mjs. Reproduce with `nix develop -c nix fmt` on the parent commit; the result should be byte-identical to this tree. None of the 13 `.prettierignore` entries appears here — verified by intersecting the changed-file list against the ignore file, with a control proving the intersection finds a match when one exists.
This commit is contained in:
parent
5d24bedd60
commit
39b95c2ede
1 changed files with 10090 additions and 6085 deletions
|
|
@ -25,19 +25,19 @@
|
|||
// own fetch callback, and it's the CALLER's job to make sure that
|
||||
// callback doesn't clobber an input the operator is mid-edit on — this
|
||||
// hook only decides *when* to call it.
|
||||
import { useEffect, useRef } from 'preact/hooks';
|
||||
import './RefreshInterval.css';
|
||||
import { useEffect, useRef } from "preact/hooks";
|
||||
import "./RefreshInterval.css";
|
||||
|
||||
// `null` means "off" throughout this module — no separate boolean, so
|
||||
// there's exactly one way to represent "not polling".
|
||||
export type RefreshIntervalMs = number | null;
|
||||
|
||||
const PRESETS: { value: RefreshIntervalMs; label: string }[] = [
|
||||
{ value: null, label: 'off' },
|
||||
{ value: 5_000, label: '5s' },
|
||||
{ value: 10_000, label: '10s' },
|
||||
{ value: 30_000, label: '30s' },
|
||||
{ value: 60_000, label: '1m' },
|
||||
{ value: null, label: "off" },
|
||||
{ value: 5_000, label: "5s" },
|
||||
{ value: 10_000, label: "10s" },
|
||||
{ value: 30_000, label: "30s" },
|
||||
{ value: 60_000, label: "1m" },
|
||||
];
|
||||
|
||||
export function RefreshIntervalPicker({
|
||||
|
|
@ -94,7 +94,10 @@ export function RefreshIntervalPicker({
|
|||
// should default its own `intervalMs` state to a real cadence, not
|
||||
// `null`, and add a separate mount effect only if it genuinely wants
|
||||
// "off" to still mean "load once."
|
||||
export function useRefreshInterval(intervalMs: RefreshIntervalMs, onTick: () => void) {
|
||||
export function useRefreshInterval(
|
||||
intervalMs: RefreshIntervalMs,
|
||||
onTick: () => void,
|
||||
) {
|
||||
// Always-current via a ref rather than a `useEffect` dependency:
|
||||
// callers pass an inline closure that's a new value every render, and
|
||||
// depending on it directly would re-arm the timer (losing whatever's
|
||||
|
|
@ -118,15 +121,15 @@ export function useRefreshInterval(intervalMs: RefreshIntervalMs, onTick: () =>
|
|||
id = undefined;
|
||||
};
|
||||
|
||||
if (document.visibilityState === 'visible') start();
|
||||
if (document.visibilityState === "visible") start();
|
||||
const onVisibility = () => {
|
||||
if (document.visibilityState === 'visible') start();
|
||||
if (document.visibilityState === "visible") start();
|
||||
else stop();
|
||||
};
|
||||
document.addEventListener('visibilitychange', onVisibility);
|
||||
document.addEventListener("visibilitychange", onVisibility);
|
||||
return () => {
|
||||
stop();
|
||||
document.removeEventListener('visibilitychange', onVisibility);
|
||||
document.removeEventListener("visibilitychange", onVisibility);
|
||||
};
|
||||
}, [intervalMs]);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue