From 101c3e68aa18814dcc18a813958e1aa0f76bd7a7 Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Fri, 23 Oct 2026 15:01:14 +0200 Subject: notify: one "balloon on screen" check, NotifyConfig.shown The desktop companion needs to know when a balloon is showing in her corner, and the rule lived inline in NotificationBalloon's visible binding. It moves to the shared library so both shells ask the same function: drawer, snooze, mute, DND, then expiry. Shared files do not hot-reload through their links: restart the notifications and desktop shells after pulling this. Co-Authored-By: Claude Opus 5.5 --- shared/NotifyConfig.js | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'shared/NotifyConfig.js') diff --git a/shared/NotifyConfig.js b/shared/NotifyConfig.js index 143168f..6fc98e6 100644 --- a/shared/NotifyConfig.js +++ b/shared/NotifyConfig.js @@ -71,6 +71,16 @@ function withheld(cfg, n, dnd) { return dnd && !(n.urgency === "critical" && cfg.dndPassCritical); } +// Whether a queued notification's balloon is on screen at `now`: the drawer +// and snooze withhold everything, then mute and DND, then its own expiry. +// The balloon shell and the desktop companion both ask this, so they cannot +// disagree about what is showing. +function shown(cfg, n, dnd, drawerOpen, snoozeUntil, now) { + if (drawerOpen || snoozeUntil > now) return false; + if (withheld(cfg, n, dnd)) return false; + return n.expires === 0 || now < n.expires; +} + // The file a balloon plays, "" for none: the app's suppress-sound wins, then // the app's own sound (notifyd resolved its hints), then the urgency's. function soundFor(cfg, n) { -- cgit v1.2.3