forked from Blendman974/faceclaw
Status bar timer widget is selectable
This commit is contained in:
1 parent
132b90c21d
commit
9a0c843bc7
7 files changed
+68
-16
No files matched your search
@@ -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);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user