From 13249f381359ea9e4f2af130b105c053bf3ab987 Mon Sep 17 00:00:00 2001 From: tamaina Date: Fri, 26 Nov 2021 13:43:11 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20notification.vue=E3=81=AEIntersectionObs?= =?UTF-8?q?erver=E3=81=BE=E3=82=8F=E3=82=8A=E3=82=92=E4=BF=AE=E6=AD=A3=20(?= =?UTF-8?q?#8010)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix notification.vue * remove a blank line * disconnect intersection observer * disconnect2 * Update packages/client/src/components/notification.vue Co-authored-by: Acid Chicken (硫酸鶏) * disconnect * oops Co-authored-by: Acid Chicken (硫酸鶏) --- .../client/src/components/notification.vue | 21 ++++++++----------- 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/packages/client/src/components/notification.vue b/packages/client/src/components/notification.vue index 89025b72e..5cf44f4c5 100644 --- a/packages/client/src/components/notification.vue +++ b/packages/client/src/components/notification.vue @@ -107,28 +107,25 @@ export default defineComponent({ const reactionRef = ref(null); onMounted(() => { - let readObserver: IntersectionObserver | null = null; - let connection = null; - if (!props.notification.isRead) { - readObserver = new IntersectionObserver((entries, observer) => { + const readObserver = new IntersectionObserver((entries, observer) => { if (!entries.some(entry => entry.isIntersecting)) return; os.stream.send('readNotification', { id: props.notification.id }); - entries.map(({ target }) => observer.unobserve(target)); + observer.disconnect(); }); readObserver.observe(elRef.value); - connection = os.stream.useChannel('main'); - connection.on('readAllNotifications', () => readObserver.unobserve(elRef.value)); - } + const connection = os.stream.useChannel('main'); + connection.on('readAllNotifications', () => readObserver.disconnect()); - onUnmounted(() => { - if (readObserver) readObserver.unobserve(elRef.value); - if (connection) connection.dispose(); - }); + onUnmounted(() => { + readObserver.disconnect(); + connection.dispose(); + }); + } }); const followRequestDone = ref(false);