mirror of
https://iceshrimp.dev/limepotato/jormungandr-bite.git
synced 2024-11-22 09:57:29 -07:00
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: Acid Chicken (硫酸鶏) <root@acid-chicken.com> * disconnect * oops Co-authored-by: Acid Chicken (硫酸鶏) <root@acid-chicken.com>
This commit is contained in:
parent
f0441331e6
commit
13249f3813
1 changed files with 9 additions and 12 deletions
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue