From faacbb2757ecbe947d6a6534d28da5c815f5b3ff Mon Sep 17 00:00:00 2001
From: Owen Jacobson <owen@grimoire.ca>
Date: Mon, 5 May 2025 20:44:00 -0400
Subject: Don't try to scroll the last message into view when there is no last
 message.

This was generating a DOM-related error viewing any empty channel:

    TypeError: null is not an object (evaluating 'document.querySelector('.message-run:last-child .message:last-child').scrollIntoView')

Harmless in practice, but easily fixed and it keeps the console from filling up with natter.
---
 ui/lib/components/ActiveChannel.svelte | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'ui/lib/components/ActiveChannel.svelte')

diff --git a/ui/lib/components/ActiveChannel.svelte b/ui/lib/components/ActiveChannel.svelte
index 30b8385..c38d10d 100644
--- a/ui/lib/components/ActiveChannel.svelte
+++ b/ui/lib/components/ActiveChannel.svelte
@@ -6,7 +6,7 @@
   $effect(() => {
     // This is just to force it to track messageRuns.
     const _ = messageRuns;
-    document.querySelector('.message-run:last-child .message:last-child').scrollIntoView();
+    document.querySelector('.message-run:last-child .message:last-child')?.scrollIntoView();
   });
 </script>
 
-- 
cgit v1.2.3

