Status bar timer widget is selectable

This commit is contained in:
James Babcock committed 2026-10-14 01:35:15 -07:00
1 parent 132b90c21d
commit 9a0c843bc7
7 files changed
+68 -16

No files matched your search

+10
View File
@@ -185,6 +185,16 @@ export function sortTimers(timers: readonly CountdownTimer[], nowMs: number): Co
});
}
/** The running timer that ends soonest (the one the tray icon counts down); null when none runs. */
export function soonestRunningTimer(timers: readonly CountdownTimer[], nowMs: number): CountdownTimer | null {
let soonest: CountdownTimer | null = null;
for (const timer of timers) {
if (timer.endsAtMs === null || timer.rungAtMs !== null) continue;
if (!soonest || timerRemainingMs(timer, nowMs) < timerRemainingMs(soonest, nowMs)) soonest = timer;
}
return soonest;
}
export function pushRecentDuration(recent: readonly number[], durationMs: number): number[] {
return [durationMs, ...recent.filter((value) => value !== durationMs)].slice(0, RECENT_DURATION_COUNT);
}