From 7c38cda8eecaf1dd54971400d8cfb568a9dc8023 Mon Sep 17 00:00:00 2001 From: tamaina Date: Sun, 31 May 2020 14:57:22 +0900 Subject: [PATCH] Refactor --- src/client/components/notification.vue | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/client/components/notification.vue b/src/client/components/notification.vue index 4fde7d3748..6c423fdecd 100644 --- a/src/client/components/notification.vue +++ b/src/client/components/notification.vue @@ -91,21 +91,23 @@ export default Vue.extend({ followRequestDone: false, groupInviteDone: false, connection: null, - readObserver: new IntersectionObserver((entries, observer) => { - if (!entries.some(entry => entry.isIntersecting)) return; - this.$root.stream.send('readNotification', { - id: this.notification.id - }); - entries.map(({ target }) => observer.unobserve(target)); - }), + readObserver: null, faIdCardAlt, faPlus, faQuoteLeft, faQuoteRight, faRetweet, faReply, faAt, faClock, faCheck, faPollH }; }, mounted() { - if (!this.notification.isRead) { + if (!this.notification.isRead ) { + this.readObserver = new IntersectionObserver((entries, observer) => { + if (!entries.some(entry => entry.isIntersecting)) return; + this.$root.stream.send('readNotification', { + id: this.notification.id + }); + entries.map(({ target }) => observer.unobserve(target)); + }) + this.readObserver.observe(this.$el); - + this.connection = this.$root.stream.useSharedConnection('main'); this.connection.on('readAllNotifications', () => this.readObserver.unobserve(this.$el)); }