From 1eec6338e1146439b1dbc6207843fbc44dd13088 Mon Sep 17 00:00:00 2001 From: Owen Jacobson Date: Wed, 30 Oct 2024 18:01:48 -0400 Subject: Don't leave field binding vars uninitialized. This was causing problems for changing passwords: if the user didn't type anything in the "original password" field, the code path to sending that field to the server was just straight-up omitting the field from the message, rather than setting it to empty string, causing a 422 Unprocessable Entity. On investigation we had latent bugs related to this in a bunch of spots. --- ui/lib/components/CreateChannelForm.svelte | 9 +++++---- ui/lib/components/MessageInput.svelte | 10 +++++----- 2 files changed, 10 insertions(+), 9 deletions(-) (limited to 'ui/lib/components') diff --git a/ui/lib/components/CreateChannelForm.svelte b/ui/lib/components/CreateChannelForm.svelte index ddcf486..b716736 100644 --- a/ui/lib/components/CreateChannelForm.svelte +++ b/ui/lib/components/CreateChannelForm.svelte @@ -1,16 +1,17 @@ diff --git a/ui/lib/components/MessageInput.svelte b/ui/lib/components/MessageInput.svelte index b2746e0..03ac7fa 100644 --- a/ui/lib/components/MessageInput.svelte +++ b/ui/lib/components/MessageInput.svelte @@ -5,16 +5,16 @@ export let channel = null; let input; let value = ''; - let sending = false; + let pending = false; - $: disabled = (channel === null); + $: disabled = pending || (channel === null); async function handleSubmit() { if (channel !== null) { - sending = true; + pending = true; // TODO try/catch: await postToChannel(channel, value); - sending = false; + pending = false; value = ''; await tick(); input.focus(); @@ -23,6 +23,6 @@
- +
-- cgit v1.2.3 From a356546fc706b2ade758e7f42069e6d669330421 Mon Sep 17 00:00:00 2001 From: Owen Jacobson Date: Wed, 30 Oct 2024 18:50:01 -0400 Subject: Coalesce adjacent messages by the same author into runs, to consolidate message display. --- ui/lib/components/ActiveChannel.svelte | 27 +++++++++++++++++++++++++-- ui/lib/components/Message.svelte | 21 +++++---------------- ui/lib/components/MessageRun.svelte | 20 ++++++++++++++++++++ ui/lib/store/messages.js | 3 --- 4 files changed, 50 insertions(+), 21 deletions(-) create mode 100644 ui/lib/components/MessageRun.svelte (limited to 'ui/lib/components') diff --git a/ui/lib/components/ActiveChannel.svelte b/ui/lib/components/ActiveChannel.svelte index ece9f55..1b23bc1 100644 --- a/ui/lib/components/ActiveChannel.svelte +++ b/ui/lib/components/ActiveChannel.svelte @@ -1,10 +1,33 @@
- {#each messageList as message} + {#each chunkBy(messageList, msg => msg.sender) as [sender, messages]}
- +
{/each}
diff --git a/ui/lib/components/Message.svelte b/ui/lib/components/Message.svelte index d040433..ef8ea0b 100644 --- a/ui/lib/components/Message.svelte +++ b/ui/lib/components/Message.svelte @@ -1,33 +1,22 @@ -
- - - @{name}: - +
{at} -
+
diff --git a/ui/lib/components/MessageRun.svelte b/ui/lib/components/MessageRun.svelte new file mode 100644 index 0000000..b998a8b --- /dev/null +++ b/ui/lib/components/MessageRun.svelte @@ -0,0 +1,20 @@ + + +
+ + + @{name}: + + {#each messages as { at, body }} + + {/each} +
diff --git a/ui/lib/store/messages.js b/ui/lib/store/messages.js index 931b8fb..7d1fbe1 100644 --- a/ui/lib/store/messages.js +++ b/ui/lib/store/messages.js @@ -17,9 +17,6 @@ export class Messages { for (let { channel, id, at, sender, body } of messages) { this.inChannel(channel).push({ id, at, sender, body, }); } - for (let channel in this.channels) { - this.channels[channel].sort((a, b) => a.at - b.at); - } return this; } -- cgit v1.2.3 From 35b8a914b867237c9c64f33838b1e1f85fc46fb8 Mon Sep 17 00:00:00 2001 From: Owen Jacobson Date: Wed, 30 Oct 2024 18:55:32 -0400 Subject: Nicer margins --- ui/lib/components/Message.svelte | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ui/lib/components') diff --git a/ui/lib/components/Message.svelte b/ui/lib/components/Message.svelte index ef8ea0b..004a484 100644 --- a/ui/lib/components/Message.svelte +++ b/ui/lib/components/Message.svelte @@ -7,7 +7,7 @@
{at} -
+
-- cgit v1.2.3