Collapse identical notifications from the same sender into one toast (#13522)
* Collapse identical notifications from the same sender into one toast A web app open in several tabs fires one notification per tab for a single reminder, stacking identical toasts. A new notification matching an on-screen toast's app, summary, and body now replaces it like a replaces_id update. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Only collapse live duplicates that share image and click target Screen recording toasts share text but preview and open different files, and replayed history rows share images with entries still in history. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Compare a notification's current content when collapsing duplicates A replaces_id update can land while the insert is deferred, so the initial snapshot may no longer describe what the notification says. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
f814639556
commit
de63134b88
3 files changed
+85
No files matched your search
@@ -189,6 +189,7 @@ Item {
|
||||
// Repeater is mid-incubation while we mutate its model.
|
||||
Qt.callLater(function() {
|
||||
removePopupsByOriginalId(snapshot.originalId, NotificationLogic.popupFileName(snapshot))
|
||||
removeDuplicatePopups(service.currentContent(notification, snapshot))
|
||||
popupModel.insert(0, snapshot)
|
||||
// An update that arrived while the insert was deferred found no row to
|
||||
// write to, and a property that already changed will not change again.
|
||||
@@ -310,6 +311,40 @@ Item {
|
||||
}
|
||||
}
|
||||
|
||||
// What the notification says now: a replaces_id update may have landed
|
||||
// while its insert was deferred, and the snapshot still holds the original.
|
||||
function currentContent(notification, snapshot) {
|
||||
try {
|
||||
return NotificationLogic.replacementSnapshot(notification, snapshot.originalId, snapshot.timestamp)
|
||||
} catch (e) {
|
||||
// Torn down by the server meanwhile — the snapshot is all there is.
|
||||
return snapshot
|
||||
}
|
||||
}
|
||||
|
||||
// A notification repeating a toast already on screen takes its place, the
|
||||
// same way a replaces_id update would: the newest copy stays, its timer
|
||||
// starts fresh, and history keeps a single entry. The superseded copy is
|
||||
// dismissed at the server so its sender stops holding it open.
|
||||
// Only toasts with a live notification behind them qualify: a restored or
|
||||
// replayed row shares its images with an entry already in history, and
|
||||
// deleting its file here would leave that entry pointing at nothing.
|
||||
function removeDuplicatePopups(snapshot) {
|
||||
for (var i = popupModel.count - 1; i >= 0; i--) {
|
||||
var row = popupModel.get(i)
|
||||
if (!NotificationLogic.isDuplicatePopup(row, snapshot) || isRestoredRow(row)) continue
|
||||
var ref = liveRefs[row.originalId]
|
||||
if (!ref) continue
|
||||
deletePopupFileFor(row)
|
||||
popupModel.remove(i)
|
||||
try {
|
||||
if (ref.tracked) ref.dismiss()
|
||||
} catch (e) {
|
||||
// Object already torn down by the server — nothing to dismiss.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function dismissPopup(index) {
|
||||
removePopup(index, "dismiss")
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user