Skip to content

Commit 4ffade4

Browse files
author
Connor Byrne
committed
fix: acknowledge a new run ahead of outcome banners
Outcome banners (completed/failed) report history; a run acknowledgement reports the action the user just took and is the only notification that can still inform them. Let queuedPending/queued preempt an active outcome banner and jump the pending queue, instead of waiting out a 4s FIFO drain. Acknowledgement-vs-acknowledgement ordering is unchanged.
1 parent c9440fc commit 4ffade4

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

src/composables/queue/useQueueNotificationBanners.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@ export type QueueNotificationBanner =
3636
| QueueCompletedNotification
3737
| QueueFailedNotification
3838

39+
const isRunAcknowledgement = (notification: QueueNotificationBanner) =>
40+
notification.type === 'queuedPending' || notification.type === 'queued'
41+
42+
const isOutcome = (notification: QueueNotificationBanner) =>
43+
notification.type === 'completed' || notification.type === 'failed'
44+
3945
const sanitizeCount = (value: number | undefined) => {
4046
if (!(typeof value === 'number' && value > 0)) {
4147
return 1
@@ -102,6 +108,22 @@ export const useQueueNotificationBanners = () => {
102108
}
103109

104110
const queueNotification = (notification: QueueNotificationBanner) => {
111+
// An outcome banner reports history; a run acknowledgement reports the
112+
// action the user just took and is the only one that can still inform them.
113+
if (isRunAcknowledgement(notification)) {
114+
const active = activeNotification.value
115+
if (active === null || isOutcome(active)) {
116+
clearDismissTimer()
117+
activeNotification.value = null
118+
pendingNotifications.value = [
119+
notification,
120+
...pendingNotifications.value
121+
]
122+
showNextNotification()
123+
return
124+
}
125+
}
126+
105127
pendingNotifications.value = [...pendingNotifications.value, notification]
106128
showNextNotification()
107129
}

0 commit comments

Comments
 (0)