Notifications UI: limit entries, improve grouping (#23241)

Co-authored-by: Michael Geers <michael@geers.tv>
This commit is contained in:
Thomas Speer 2025-08-25 20:44:16 +02:00 • committed by GitHub
parent e00017d55b
commit cb33486843
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -33,18 +33,21 @@ const app = createApp(
if (this.offline) return;
if (!msg.level) msg.level = "error";
const now = new Date();
const latestMsg = this.notifications[0];
if (latestMsg && latestMsg.message === msg.message && latestMsg.lp === msg.lp) {
latestMsg.count++;
latestMsg.time = now;
const existingMsg = this.notifications.find(
(n) => n.message === msg.message && n.lp === msg.lp
);
if (existingMsg) {
existingMsg.count++;
existingMsg.time = now;
// move to front
this.notifications = [
existingMsg,
...this.notifications.filter((n) => n !== existingMsg),
];
} else {
this.notifications = [
{
...msg,
count: 1,
time: now,
},
...this.notifications,
{ ...msg, count: 1, time: now },
...this.notifications.slice(0, 14), // keep only last 15
];
}
},