refactor(notifications): Centralize dismissal logic in NotificationService

This commit is contained in:
loner
2025-10-13 04:43:52 +08:00
parent 6eee4aeb9e
commit 8eab276ee3
2 changed files with 8 additions and 4 deletions

View File

@@ -45,10 +45,7 @@ Item {
}
function dismissOldest() {
if (NotificationService.activeList.count > 0) {
const lastNotif = NotificationService.activeList.get(NotificationService.activeList.count - 1)
NotificationService.dismissActiveNotification(lastNotif.id)
}
NotificationService.dismissOldestActive()
}
function dismissAll() {

View File

@@ -414,6 +414,13 @@ Singleton {
removeActive(id)
}
function dismissOldestActive() {
if (activeList.count > 0) {
const lastNotif = activeList.get(activeList.count - 1)
dismissActiveNotification(lastNotif.id)
}
}
function dismissAllActive() {
Object.values(activeMap).forEach(n => n.dismiss())
activeList.clear()