Open History to see the last commit
1export type RevealSubscription = (listener: () => void) => void;
2
3/**
4 * Wire a reveal callback to fire exactly once, on whichever of the provided
5 * event subscribers fires first. Each subscriber is responsible for binding
6 * its own event source.
7 *
8 * Used by the desktop main window's first-paint reveal logic. The standard
9 * Electron pattern is to wait for `ready-to-show` before calling `show()`,
10 * but on Linux/Wayland with `show: false`, `ready-to-show` only fires after
11 * `show()` is called, deadlocking that pattern. Subscribing to both
12 * `ready-to-show` and `did-finish-load` (or any other "renderer is alive"
13 * signal) lets the window surface reliably across platforms.
14 */
15export function bindFirstRevealTrigger(
16 subscribers: readonly RevealSubscription[],
17 reveal: () => void,
18): void {
19 let revealed = false;
20 const fire = () => {
21 if (revealed) return;
22 revealed = true;
23 reveal();
24 };
25 for (const subscribe of subscribers) {
26 subscribe(fire);
27 }
28}