diff options
| author | Danilo M. <danix@danix.xyz> | 2026-10-23 15:01:14 +0200 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-10-23 15:01:14 +0200 |
| commit | 101c3e68aa18814dcc18a813958e1aa0f76bd7a7 (patch) | |
| tree | baa1d7082ae0385333c3ffe79d49871621b3e8d6 /shared/test_notify_config.js | |
| parent | 231a7da0f9b4b8b007617fe12414c794f9374ee0 (diff) | |
| download | quickshell-101c3e68aa18814dcc18a813958e1aa0f76bd7a7.tar.gz quickshell-101c3e68aa18814dcc18a813958e1aa0f76bd7a7.zip | |
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 <noreply@anthropic.com>
Diffstat (limited to 'shared/test_notify_config.js')
| -rw-r--r-- | shared/test_notify_config.js | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/shared/test_notify_config.js b/shared/test_notify_config.js index c7bc2cc..4e8db23 100644 --- a/shared/test_notify_config.js +++ b/shared/test_notify_config.js @@ -18,7 +18,7 @@ const assert = require("assert"); const src = fs.readFileSync(__dirname + "/NotifyConfig.js", "utf8") .replace(/^\.pragma library$/m, ""); -const C = new Function(src + "\nreturn { defaults, resolve, withheld, soundFor };")(); +const C = new Function(src + "\nreturn { defaults, resolve, withheld, soundFor, shown };")(); // Nothing, or garbage, is the defaults. assert.deepStrictEqual(C.resolve(undefined), C.defaults()); @@ -64,4 +64,16 @@ assert.strictEqual(C.soundFor(sc, sn("critical", "/app.oga", true)), ""); // An old daemon publishes neither field. assert.strictEqual(C.soundFor(sc, { app: "x", urgency: "critical" }), "/c.oga"); +// On screen: the drawer, snooze, mute, DND and expiry, in one check that +// the balloons and the desktop companion share. +const live = { app: "ok", urgency: "normal", expires: 0 }; +assert.strictEqual(C.shown(cfg, live, false, false, 0, 5000), true); +assert.strictEqual(C.shown(cfg, live, false, true, 0, 5000), false); // drawer open +assert.strictEqual(C.shown(cfg, live, false, false, 6000, 5000), false); // snoozed +assert.strictEqual(C.shown(cfg, { app: "spam", urgency: "normal", expires: 0 }, false, false, 0, 5000), false); +assert.strictEqual(C.shown(cfg, live, true, false, 0, 5000), false); // DND +const timed = { app: "ok", urgency: "normal", expires: 5000 }; +assert.strictEqual(C.shown(cfg, timed, false, false, 0, 4999), true); +assert.strictEqual(C.shown(cfg, timed, false, false, 0, 5000), false); // expired + console.log("ok"); |
