dotfiles bugabingas dorkfiles
owned by bugabinga
README Source History Refs Compare Notes Search notifications: independent toast countdowns via stamped expiresAt 3c353402a0a5efa39fa25d699f2554db08ed27c5
Oliver Jan Krylow <oliver@bugabinga.net > · 27 Jun 2026
unsigned
Browse files Compare with HEAD
Toast timers and drain bars restarted from full whenever any other toast
was added, removed, or a notification replaced in place, because the toast
Repeater rebuilds every delegate on each model change.
Stamp an absolute expiresAt on the toast row once, when the toast is first
accepted (replace-in-place mutates the native object without re-firing
onNotification, so it never re-stamps). The delegate's dismiss Timer and
drain animation now derive their remaining time from expiresAt, so a
rebuilt delegate resumes the countdown at its true position instead of
restarting. Each toast's expiry is independent of the others.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Changed files (2) quickshell/nuguland/Notifications.qml Modified 210 210 if (
! row.transient)
213 + const tms
= toastTimeoutMs(row);
213 214 const map
= Object .
assign ({}, toastById);
219 + map[row.id]
= Object .
assign ({}, row, {
220 + "toastTimeoutMs" : tms,
221 + "expiresAt" : tms
> 0 ? Date .
now ()
+ tms
: 0 216 224 activeToasts
= activeToasts.filter((x)
=> x
!== row.id).concat([row.id]);
282 290 rows.push(
Object .
assign ({}, row, {
283 291 "actionRows" : actionRows(row),
284 - "timeoutMs" : toastTimeoutMs(row)
292 + "timeoutMs" : row.toastTimeoutMs
!== undefined ? row.toastTimeoutMs
: toastTimeoutMs(row),
293 + "expiresAt" : row.expiresAt
|| 0 quickshell/nuguland/shell.qml Modified 315 315 onDismiss : (id)
=> notifications.dismissToast(id)
316 316 onInvokeAction : (id, actionId)
=> notifications.runAction(id, actionId)
322 + readonly property real toastTotal: toastWrap.modelData.timeoutMs
|| 0 323 + readonly property real toastExpiry: toastWrap.modelData.expiresAt
|| 0 324 + readonly property real toastRemaining:
Math .max(
0 , toastExpiry
- Date .
now ())
319 - running : (toastWrap.modelData.timeoutMs
|| 0 )
> 0 320 - interval :
Math .
max (
1 , toastWrap.modelData.timeoutMs
|| 0 )
326 + running : toastWrap.toastExpiry
> 0 327 + interval :
Math .
max (
1 , toastWrap.toastRemaining)
322 329 onTriggered : notifications.dismissToast(
String (toastWrap.modelData.id))
328 - visible : (toastWrap.modelData.timeoutMs
|| 0 )
> 0 336 + visible : toastWrap.toastExpiry
> 0 329 337 anchors.left: toastCard.left
330 338 anchors.bottom: toastCard.bottom
331 339 anchors.leftMargin:
12 335 343 color: nuguTheme
? nuguTheme.withAlpha(nuguTheme.ui.accent,
0.55 )
: "transparent" 336 - width: toastCard.width
- 24 344 + width: (toastCard.width
- 24 )
* (toastWrap.toastTotal
> 0 ? toastWrap.toastRemaining
/ toastWrap.toastTotal
: 1 )
337 345 NumberAnimation on width {
338 - running : (toastWrap.modelData.timeoutMs
|| 0 )
> 0 && ! (nuguTheme
&& nuguTheme.lowPowerMode)
339 - from : toastCard.width
- 24 346 + running : toastWrap.toastExpiry
> 0 && ! (nuguTheme
&& nuguTheme.lowPowerMode)
341 - duration :
Math .
max (
1 , toastWrap.modelData.timeoutMs
|| 0 )
348 + duration :
Math .
max (
1 , toastWrap.toastRemaining)