From 9fbf0469577bf0a16952b540c49a6a52c7be65f9 Mon Sep 17 00:00:00 2001 From: tamaina Date: Tue, 26 May 2020 15:00:15 +0900 Subject: [PATCH] capture readAllNotifications --- src/client/components/notification.vue | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/client/components/notification.vue b/src/client/components/notification.vue index d0c85b6e2..3c6b8524e 100644 --- a/src/client/components/notification.vue +++ b/src/client/components/notification.vue @@ -90,6 +90,7 @@ export default Vue.extend({ getNoteSummary: (text: string) => noteSummary(text, this.$root.i18n.messages[this.$root.i18n.locale]), followRequestDone: false, groupInviteDone: false, + connection: null, readObserver: new IntersectionObserver((entries, observer) => { if (!entries.some(entry => entry.isIntersecting)) return; this.$root.stream.send('readNotification', { @@ -102,11 +103,17 @@ export default Vue.extend({ }, mounted() { - if (!this.notification.isRead) this.readObserver.observe(this.$el); + if (!this.notification.isRead) { + this.readObserver.observe(this.$el); + + this.connection = this.$root.stream.useSharedConnection('main'); + this.connection.on('readAllNotifications', () => this.readObserver.unobserve(this.$el)); + } }, beforeDestroy() { if (!this.notification.isRead) this.readObserver.unobserve(this.$el); + this.connection.dispose(); }, methods: {