From f95ca164d63ea372e812b61e3c622a5cd4fe7400 Mon Sep 17 00:00:00 2001 From: tamaina Date: Wed, 10 Feb 2021 01:54:07 +0900 Subject: [PATCH] wip --- src/client/components/notification.vue | 13 +- src/client/components/notifications.vue | 15 ++ src/client/scripts/mark-notification-read.ts | 3 + src/client/sw/compose-notification.ts | 107 --------------- src/client/sw/lang.ts | 44 ++++++ src/client/sw/notification.ts | 137 +++++++++++++++++++ src/client/sw/sw.ts | 97 +++++-------- src/server/api/common/read-notification.ts | 11 +- src/services/create-notification.ts | 4 +- src/services/messages/create.ts | 2 +- src/services/push-notification.ts | 2 +- 11 files changed, 259 insertions(+), 176 deletions(-) create mode 100644 src/client/scripts/mark-notification-read.ts delete mode 100644 src/client/sw/compose-notification.ts create mode 100644 src/client/sw/lang.ts create mode 100644 src/client/sw/notification.ts diff --git a/src/client/components/notification.vue b/src/client/components/notification.vue index 2fe8500891..4ae8547162 100644 --- a/src/client/components/notification.vue +++ b/src/client/components/notification.vue @@ -68,6 +68,7 @@ import notePage from '../filters/note'; import { userPage } from '../filters/user'; import { i18n } from '@/i18n'; import * as os from '@/os'; +import { markNotificationRead } from '@/scripts/mark-notification-read'; export default defineComponent({ components: { @@ -113,7 +114,17 @@ export default defineComponent({ this.readObserver.observe(this.$el); this.connection = os.stream.useSharedConnection('main'); - this.connection.on('readAllNotifications', () => this.readObserver.unobserve(this.$el)); + + this.connection.on('readAllNotifications', () => { + this.readObserver.unobserve(this.$el); + this.notification = markNotificationRead(this.notification); + }); + this.connection.on('readNotifications', notificationIds => { + if (notificationIds.includes(this.notification.id)) { + this.readObserver.unobserve(this.$el); + this.notification = markNotificationRead(this.notification); + } + }) } }, diff --git a/src/client/components/notifications.vue b/src/client/components/notifications.vue index 9759cc2395..b19b7ff7a3 100644 --- a/src/client/components/notifications.vue +++ b/src/client/components/notifications.vue @@ -19,6 +19,7 @@