Keep unread notifications in sync with headerbar
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
import { marked } from 'marked';
|
||||
import { eachLimit } from 'async';
|
||||
import { ref, onMounted } from 'vue';
|
||||
import { ref, onMounted, inject } from 'vue';
|
||||
import { Button } from '@cloudron/pankow';
|
||||
import { prettyDate } from '@cloudron/pankow/utils';
|
||||
import NotificationsModel from '../models/NotificationsModel.js';
|
||||
@@ -12,6 +12,7 @@ const notificationsModel = NotificationsModel.create();
|
||||
const busy = ref(true);
|
||||
const notifications = ref([]);
|
||||
const notificationsAllBusy = ref(false);
|
||||
const refreshNotifications = inject('refreshNotifications');
|
||||
|
||||
async function refresh() {
|
||||
const [error, result] = await notificationsModel.list();
|
||||
@@ -30,6 +31,7 @@ async function onMarkNotificationRead(notification) {
|
||||
if (error) return console.error(error);
|
||||
|
||||
await refresh();
|
||||
refreshNotifications();
|
||||
}
|
||||
|
||||
async function onMarkNotificationUnread(notification) {
|
||||
@@ -38,6 +40,7 @@ async function onMarkNotificationUnread(notification) {
|
||||
if (error) return console.error(error);
|
||||
|
||||
await refresh();
|
||||
refreshNotifications();
|
||||
}
|
||||
|
||||
async function onMarkAllNotificationRead() {
|
||||
@@ -50,6 +53,7 @@ async function onMarkAllNotificationRead() {
|
||||
});
|
||||
|
||||
await refresh();
|
||||
refreshNotifications();
|
||||
|
||||
notificationsAllBusy.value = false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user