feat(notifications): add overlay notifications with position config (#110)

This commit is contained in:
2026-06-10 22:46:52 -07:00
committed by GitHub
parent c09d009a3e
commit 7be1843c41
177 changed files with 7524 additions and 440 deletions
+49
View File
@@ -0,0 +1,49 @@
const DEFAULT_OVERLAY_LOADING_OSD_TICK_MS = 180;
const OVERLAY_LOADING_OSD_FRAMES = ['|', '/', '-', '\\'] as const;
export function createOverlayLoadingOsdController(deps: {
showOsd: (message: string) => void;
clearOsd: () => void;
setInterval?: (callback: () => void, delayMs: number) => unknown;
clearInterval?: (timer: unknown) => void;
}) {
const setIntervalHandler =
deps.setInterval ??
((callback: () => void, delayMs: number): unknown => setInterval(callback, delayMs));
const clearIntervalHandler =
deps.clearInterval ??
((timer: unknown): void => clearInterval(timer as ReturnType<typeof setInterval>));
let active = false;
let frame = 0;
let timer: unknown = null;
const showNextFrame = (): void => {
deps.showOsd(
`Overlay loading ${OVERLAY_LOADING_OSD_FRAMES[frame % OVERLAY_LOADING_OSD_FRAMES.length]}`,
);
frame += 1;
};
return {
start(): void {
if (active) {
return;
}
active = true;
frame = 0;
showNextFrame();
timer = setIntervalHandler(showNextFrame, DEFAULT_OVERLAY_LOADING_OSD_TICK_MS);
},
stop(): void {
if (!active) {
return;
}
active = false;
if (timer !== null) {
clearIntervalHandler(timer);
timer = null;
}
deps.clearOsd();
},
};
}