fixed notification infinite scrolling

it actually infinitely scrolls :yippee:
This commit is contained in:
ari melody 2025-01-19 22:28:29 +00:00
parent 975984c4bc
commit a9160a3a8f
Signed by: ari
GPG key ID: CF99829C92678188
3 changed files with 22 additions and 12 deletions

View file

@ -13,11 +13,19 @@
}
unread_notif_count.set(0);
});
let notif_lock = true; // `true` means "open"
document.addEventListener("scroll", () => {
if (!notif_lock) return;
if ($account && $page.url.pathname !== "/notifications") return;
if (window.innerHeight + window.scrollY >= document.body.offsetHeight - 2048) {
let max_id = $notifications.length > 0 ? $notifications[$notifications.length - 1].id : null;
getNotifications(null, max_id);
notif_lock = false;
getNotifications(null, max_id).then(() => {
notif_lock = true;
});
}
});
</script>