summaryrefslogtreecommitdiff
path: root/ui
diff options
context:
space:
mode:
authorOwen Jacobson <owen@grimoire.ca>2025-02-20 22:22:57 -0500
committerOwen Jacobson <owen@grimoire.ca>2025-02-20 22:22:57 -0500
commit743b59b69857da81b214970ec9252bc918ad243d (patch)
treea0e48dcfee9acb5739b8029bb44678f72b7ccc5b /ui
parent40468057d7cb7be8203b5ec9acf178339a80a362 (diff)
Only check for message visibility while a channel is actually attached to the DOM.
Prevents this from breaking during DOM unmounting, when leaving a channel.
Diffstat (limited to 'ui')
-rw-r--r--ui/routes/(app)/ch/[channel]/+page.svelte17
1 files changed, 9 insertions, 8 deletions
diff --git a/ui/routes/(app)/ch/[channel]/+page.svelte b/ui/routes/(app)/ch/[channel]/+page.svelte
index 7bd0e10..25bc318 100644
--- a/ui/routes/(app)/ch/[channel]/+page.svelte
+++ b/ui/routes/(app)/ch/[channel]/+page.svelte
@@ -22,14 +22,15 @@
}
function getLastVisibleMessage() {
- const parentElement = activeChannel;
- const childElements = parentElement.getElementsByClassName('message');
- const lastInView = Array.from(childElements)
- .reverse()
- .find((el) => {
- return inView(parentElement, el);
- });
- return lastInView;
+ if (activeChannel) {
+ const childElements = activeChannel.getElementsByClassName('message');
+ const lastInView = Array.from(childElements)
+ .reverse()
+ .find((el) => {
+ return inView(activeChannel, el);
+ });
+ return lastInView;
+ }
}
function setLastRead() {