From ceea5f42f85a076f8240a7e18a721af689bcbcd9 Mon Sep 17 00:00:00 2001 From: tamaina Date: Tue, 11 Jan 2022 15:58:53 +0900 Subject: [PATCH] merge --- .../client/src/components/notifications.vue | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/packages/client/src/components/notifications.vue b/packages/client/src/components/notifications.vue index 31511fb515..256062b5ac 100644 --- a/packages/client/src/components/notifications.vue +++ b/packages/client/src/components/notifications.vue @@ -72,6 +72,31 @@ const noteUpdated = (item, note) => { onMounted(() => { const connection = stream.useChannel('main'); connection.on('notification', onNotification); + connection.on('readAllNotifications', () => { + if (pagingComponent.value) { + for (const item of pagingComponent.value.queue) { + item.isRead = true; + } + for (const item of pagingComponent.value.items) { + item.isRead = true; + } + } + }); + connection.on('readNotifications', notificationIds => { + if (pagingComponent.value) { + for (let i = 0; i < pagingComponent.value.queue.length; i++) { + if (notificationIds.includes(pagingComponent.value.queue[i].id)) { + pagingComponent.value.queue[i].isRead = true; + } + } + for (let i = 0; i < (pagingComponent.value.items || []).length; i++) { + if (notificationIds.includes(pagingComponent.value.items[i].id)) { + pagingComponent.value.items[i].isRead = true; + } + } + } + }); + onUnmounted(() => { connection.dispose(); });