diff options
Diffstat (limited to 'ui/lib')
| -rw-r--r-- | ui/lib/components/CreateChannelForm.svelte | 7 | ||||
| -rw-r--r-- | ui/lib/components/LogOut.svelte | 2 | ||||
| -rw-r--r-- | ui/lib/components/Message.svelte | 8 | ||||
| -rw-r--r-- | ui/lib/components/MessageInput.svelte | 8 | ||||
| -rw-r--r-- | ui/lib/store/messages.svelte.js | 6 |
5 files changed, 14 insertions, 17 deletions
diff --git a/ui/lib/components/CreateChannelForm.svelte b/ui/lib/components/CreateChannelForm.svelte index afa3f78..d50e60d 100644 --- a/ui/lib/components/CreateChannelForm.svelte +++ b/ui/lib/components/CreateChannelForm.svelte @@ -2,17 +2,16 @@ import { createChannel } from '$lib/apiServer'; let name = $state(''); - let pending = false; - let disabled = $derived(pending); + let disabled = $state(false); async function handleSubmit(event) { event.preventDefault(); - pending = true; + disabled = true; const response = await createChannel(name); if (200 <= response.status && response.status < 300) { name = ''; } - pending = false; + disabled = false; } </script> diff --git a/ui/lib/components/LogOut.svelte b/ui/lib/components/LogOut.svelte index 25dd5e9..52aa039 100644 --- a/ui/lib/components/LogOut.svelte +++ b/ui/lib/components/LogOut.svelte @@ -7,7 +7,7 @@ event.preventDefault(); const response = await logOut(); if (200 <= response.status && response.status < 300) { - currentUser.update(() => null); + currentUser.set(null); goto('/login'); } } diff --git a/ui/lib/components/Message.svelte b/ui/lib/components/Message.svelte index d77c29a..1b32c08 100644 --- a/ui/lib/components/Message.svelte +++ b/ui/lib/components/Message.svelte @@ -1,15 +1,11 @@ <script> - import { marked } from 'marked'; - import DOMPurify from 'dompurify'; - import { deleteMessage } from '$lib/apiServer'; function scroll(message) { message.scrollIntoView(); } - let { id, at, body, editable = false } = $props(); - let renderedBody = $derived(DOMPurify.sanitize(marked.parse(body, { breaks: true }))); + let { id, at, body, renderedBody, editable = false } = $props(); let deleteArmed = $state(false); function onDelete(event) { @@ -27,7 +23,7 @@ } </script> -<div class="message relative" class:bg-warning-800={deleteArmed} {onmouseleave}> +<div class="message relative" class:bg-warning-800={deleteArmed} {onmouseleave} role="article"> <div class="handle chip bg-surface-700 absolute -top-6 right-0"> {at} {#if editable} diff --git a/ui/lib/components/MessageInput.svelte b/ui/lib/components/MessageInput.svelte index 26521e1..22456f3 100644 --- a/ui/lib/components/MessageInput.svelte +++ b/ui/lib/components/MessageInput.svelte @@ -5,16 +5,14 @@ let form; let value = $state(''); - let pending = false; - - let disabled = $derived(pending); + let disabled = $state(false); async function onSubmit(event) { event.preventDefault(); - pending = true; + disabled = true; await postToChannel(channel, value); form.reset(); - pending = false; + disabled = false; } function onKeyDown(event) { diff --git a/ui/lib/store/messages.svelte.js b/ui/lib/store/messages.svelte.js index c0db71b..0ceba54 100644 --- a/ui/lib/store/messages.svelte.js +++ b/ui/lib/store/messages.svelte.js @@ -1,3 +1,6 @@ +import { marked } from 'marked'; +import DOMPurify from 'dompurify'; + const RUN_COALESCE_MAX_INTERVAL = 10 /* min */ * 60 /* sec */ * 1000; /* ms */ export class Messages { @@ -9,7 +12,8 @@ export class Messages { addMessage(channel, id, { at, sender, body }) { let parsedAt = new Date(at); - const message = { id, at: parsedAt, body }; + let renderedBody = DOMPurify.sanitize(marked.parse(body, { breaks: true })); + const message = { id, at: parsedAt, body, renderedBody }; // You might be thinking, can't this be // |
