Fix some state stuff, snapshot things in the right places

This commit is contained in:
Jon Staab
2025-02-18 17:15:41 -08:00
parent 08d8d45ecb
commit 60d107aed2
8 changed files with 34 additions and 19 deletions
@@ -46,8 +46,6 @@
const filter = {kinds: [MESSAGE], "#h": [room]}
const relay = deriveRelay(url)
const assertEvent = (e: any) => e as TrustedEvent
const joinRoom = async () => {
if (hasNip29($relay)) {
joiningRoom = true
@@ -275,7 +273,12 @@
<Divider>{value}</Divider>
{:else}
<div in:slide class:-mt-1={!showPubkey}>
<ChannelMessage {url} {room} {replyTo} event={assertEvent(value)} {showPubkey} />
<ChannelMessage
{url}
{room}
{replyTo}
event={$state.snapshot(value as TrustedEvent)}
{showPubkey} />
</div>
{/if}
{/each}
@@ -42,8 +42,6 @@
return sortBy(e => -max([scores.get(e.id), e.created_at]), threads)
})
$inspect({threads, comments, events})
onMount(() => {
const {cleanup} = makeFeed({
element: element!,
@@ -98,7 +96,7 @@
<div class="flex flex-grow flex-col gap-2 overflow-auto p-2">
{#each events as event (event.id)}
<div in:fly>
<ThreadItem {url} {event} />
<ThreadItem {url} event={$state.snapshot(event)} />
</div>
{/each}
<p class="flex h-10 items-center justify-center py-20">