From 215b0c5cb2ff0ef0b2c7b5549704e23d651a4df9 Mon Sep 17 00:00:00 2001
From: Owen Jacobson <owen@grimoire.ca>
Date: Thu, 10 Oct 2024 21:51:10 -0400
Subject: Hoist the UI one step up further

---
 ui/lib/components/ActiveChannel.svelte | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)
 create mode 100644 ui/lib/components/ActiveChannel.svelte

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

diff --git a/ui/lib/components/ActiveChannel.svelte b/ui/lib/components/ActiveChannel.svelte
new file mode 100644
index 0000000..978e952
--- /dev/null
+++ b/ui/lib/components/ActiveChannel.svelte
@@ -0,0 +1,27 @@
+<script>
+    import { activeChannel, messages } from '$lib/store';
+    import Message from './Message.svelte';
+
+    let container;
+    $: messageList = $activeChannel.isSet() ? $messages.inChannel($activeChannel.get()) : [];
+
+    // TODO: eventually, store scroll height/last unread in channel? scroll there?
+
+    let scroll = (message) => {
+        message.scrollIntoView();
+    }
+</script>
+
+<div class="container" bind:this={container}>
+    {#each messageList as message}
+        <div use:scroll>
+            <Message {...message} />
+        </div>
+    {/each}
+</div>
+
+<style>
+    .container {
+        overflow: scroll;
+    }
+</style>
-- 
cgit v1.2.3

