fix notification.vue

This commit is contained in:
tamaina 2021-11-22 16:01:28 +09:00
parent aaba43e754
commit 701b5a1dec
1 changed files with 7 additions and 9 deletions

View File

@ -107,11 +107,8 @@ export default defineComponent({
const reactionRef = ref(null); const reactionRef = ref(null);
onMounted(() => { onMounted(() => {
let readObserver: IntersectionObserver | null = null;
let connection = null;
if (!props.notification.isRead) { if (!props.notification.isRead) {
readObserver = new IntersectionObserver((entries, observer) => { const readObserver = new IntersectionObserver((entries, observer) => {
if (!entries.some(entry => entry.isIntersecting)) return; if (!entries.some(entry => entry.isIntersecting)) return;
os.stream.send('readNotification', { os.stream.send('readNotification', {
id: props.notification.id id: props.notification.id
@ -121,14 +118,15 @@ export default defineComponent({
readObserver.observe(elRef.value); readObserver.observe(elRef.value);
connection = os.stream.useChannel('main'); const connection = os.stream.useChannel('main');
connection.on('readAllNotifications', () => readObserver.unobserve(elRef.value)); connection.on('readAllNotifications', () => readObserver.unobserve(elRef.value));
}
onUnmounted(() => { onUnmounted(() => {
if (readObserver) readObserver.unobserve(elRef.value); if (readObserver) readObserver.unobserve(elRef.value);
if (connection) connection.dispose(); if (connection) connection.dispose();
}); });
}
}); });
const followRequestDone = ref(false); const followRequestDone = ref(false);