Show unread notifications by default and purge them on read

This commit is contained in:
Johannes Zellner
2026-01-23 14:08:46 +01:00
parent c4f8f318af
commit d0fb2583a5
2 changed files with 14 additions and 4 deletions
+13 -3
View File
@@ -13,7 +13,7 @@ const busy = ref(true);
const notifications = ref([]);
const notificationsAllBusy = ref(false);
const refreshNotifications = inject('refreshNotifications');
const showAll = ref(true);
const showAll = ref(false);
async function refresh() {
const [error, result] = await notificationsModel.list(showAll.value ? null : false);
@@ -31,8 +31,17 @@ async function onMarkNotificationRead(notification) {
const [error] = await notificationsModel.update(notification.id, true);
if (error) return console.error(error);
await refresh();
notification.busy = false;
notification.acknowledged = true;
refreshNotifications();
if (!showAll.value) {
setTimeout(() => {
const idx = notifications.value.findIndex(n => n.id === notification.id);
if (idx === -1) return;
notifications.value.splice(idx, 1);
}, 500);
}
}
async function onMarkNotificationUnread(notification) {
@@ -40,7 +49,8 @@ async function onMarkNotificationUnread(notification) {
const [error] = await notificationsModel.update(notification.id, false);
if (error) return console.error(error);
await refresh();
notification.busy = false;
notification.acknowledged = false;
refreshNotifications();
}