From 2f0b77e8fd02a137047c8975a573626cd76310ff Mon Sep 17 00:00:00 2001
From: Owen Jacobson <owen@grimoire.ca>
Date: Wed, 9 Oct 2024 01:43:34 -0400
Subject: Return a flat message list on boot, not nested lists by channel.

This is a bit easier to compute, and sets us up nicely for pulling message boot out of the `/api/boot` response entirely.
---
 hi-ui/src/routes/+page.svelte | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)

(limited to 'hi-ui/src/routes/+page.svelte')

diff --git a/hi-ui/src/routes/+page.svelte b/hi-ui/src/routes/+page.svelte
index 39f8b62..dd5f2f7 100644
--- a/hi-ui/src/routes/+page.svelte
+++ b/hi-ui/src/routes/+page.svelte
@@ -18,20 +18,13 @@
     });
 
     function onBooted(boot) {
-        logins.update((value) => value.addLogins(boot.logins));
         currentUser.update(() => ({
             id: boot.login.id,
             username: boot.login.name,
         }));
-        let channels = boot.channels.map((channel) => ({
-            id: channel.id,
-            name: channel.name,
-        }));
-        channelsList.update((value) => value.setChannels(channels));
-        let bootMessages = boot.channels.map((channel) => [channel.id, channel.messages]);
-        for (let [channel, channelMessages] of bootMessages) {
-            messages.update((value) => value.addMessages(channel, channelMessages));
-        }
+        logins.update((value) => value.setLogins(boot.logins));
+        channelsList.update((value) => value.setChannels(boot.channels));
+        messages.update((value) => value.setMessages(boot.messages));
     }
 
 	onMount(async () => {
@@ -39,6 +32,7 @@
             let response = await boot();
             switch (response.status) {
                 case 200:
+                    debugger;
                     onBooted(response.data);
                     subscribeToEvents(response.data.resume_point);
                     break;
-- 
cgit v1.2.3

