Show unread notifications by default and purge them on read
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user