Skip to content
Snippets Groups Projects
Unverified Commit 8e0108a0 authored by tamaina's avatar tamaina Committed by GitHub
Browse files

fix: notification.vueのIntersectionObserverまわりを修正 (#8010)


* fix notification.vue

* remove a blank line

* disconnect intersection observer

* disconnect2

* Update packages/client/src/components/notification.vue

Co-authored-by: default avatarAcid Chicken (硫酸鶏) <root@acid-chicken.com>

* disconnect

* oops

Co-authored-by: default avatarAcid Chicken (硫酸鶏) <root@acid-chicken.com>
parent d9775c14
No related branches found
No related tags found
No related merge requests found
......@@ -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);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment