summaryrefslogtreecommitdiff
path: root/ui/lib/components/MessageRun.svelte
diff options
context:
space:
mode:
authorOwen Jacobson <owen@grimoire.ca>2025-02-15 15:17:03 -0500
committerOwen Jacobson <owen@grimoire.ca>2025-02-21 17:49:38 -0500
commitfc0f1654a56d2247728a766f43e72ff169704888 (patch)
tree945f44c9a90bf51de20c61a5a8c5ed82c2c05009 /ui/lib/components/MessageRun.svelte
parent36cadfe00cacc6a6523f9862d3f7a08a9d0ce611 (diff)
Hoist global state access out of individual components.
Access to "global" (maybe "external?") state is now handled at the top level of the component hierarchy, in `+page.svelte`, `+layout.svelte`, and their associated scripts. State is otherwise passed down through props, and changes are passed up through callbacks. This is - hopefully - groundwork for refactoring state management a bit. I wanted to move access to state out to a smaller number of places, so that I have fewer places to update to implement reconnect logic. My broader goal is to make it easier to refactor these kinds of external side effects, as well, though no such changes are in this branch. This change also makes testing a mile easier, since tests can interact with props and callbacks instead of emulating the whole HTTP request stack and the Pilcrow API. This change removes do-very-little tests.
Diffstat (limited to 'ui/lib/components/MessageRun.svelte')
-rw-r--r--ui/lib/components/MessageRun.svelte10
1 files changed, 3 insertions, 7 deletions
diff --git a/ui/lib/components/MessageRun.svelte b/ui/lib/components/MessageRun.svelte
index bee64e8..f1facd3 100644
--- a/ui/lib/components/MessageRun.svelte
+++ b/ui/lib/components/MessageRun.svelte
@@ -1,18 +1,14 @@
<script>
- import { logins, currentUser } from '$lib/store';
import Message from '$lib/components/Message.svelte';
- let { sender, messages } = $props();
-
- let name = $derived($logins.get(sender));
- let ownMessage = $derived($currentUser !== null && $currentUser.id == sender);
+ let { sender, messages, ownMessage, deleteMessage = async (id) => {} } = $props();
</script>
<div class="message-run" class:own-message={ownMessage} class:other-message={!ownMessage}>
<span class="username">
- @{name}:
+ @{sender}:
</span>
{#each messages as message}
- <Message {...message} editable={ownMessage} />
+ <Message {...message} editable={ownMessage} {deleteMessage} />
{/each}
</div>