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
@@ -10,12 +10,18 @@
import {publishReaction} from "@app/commands"
import {pushModal} from "@app/modal"
const {url, event, reply} = $props()
type Props = {
url: string
event: TrustedEvent
reply: () => void
}
const {url, event, reply}: Props = $props()
const onEmoji = ((event: TrustedEvent, url: string, emoji: NativeEmoji) => {
history.back()
publishReaction({event, relays: [url], content: emoji.unicode})
}).bind(undefined, $state.snapshot(event), url)
}).bind(undefined, event, url)
const showEmojiPicker = () => pushModal(EmojiPicker, {onClick: onEmoji}, {replaceState: true})
+5 -3
View File
@@ -42,8 +42,6 @@
const others = remove($pubkey!, pubkeys)
const missingInboxes = $derived(pubkeys.filter(pk => !$inboxRelaySelectionsByPubkey.has(pk)))
const assertEvent = (e: any) => e as TrustedEvent
const showMembers = () =>
pushModal(ProfileList, {pubkeys: others, title: `People in this conversation`})
@@ -196,7 +194,11 @@
{#if type === "date"}
<Divider>{value}</Divider>
{:else}
<ChatMessage event={assertEvent(value)} {pubkeys} {showPubkey} {replyTo} />
<ChatMessage
event={$state.snapshot(value as TrustedEvent)}
{pubkeys}
{showPubkey}
{replyTo} />
{/if}
{/each}
<p
@@ -14,7 +14,7 @@
const onEmoji = ((event: TrustedEvent, emoji: NativeEmoji) => {
history.back()
sendWrapped({template: makeReaction({event, content: emoji.unicode}), pubkeys})
}).bind(undefined, $state.snapshot(event))
}).bind(undefined, event)
const showEmojiPicker = () => pushModal(EmojiPicker, {onClick: onEmoji}, {replaceState: true})
+8 -4
View File
@@ -1,14 +1,18 @@
<script lang="ts">
import type {TrustedEvent} from "@welshman/util"
import Confirm from "@lib/components/Confirm.svelte"
import {publishDelete} from "@app/commands"
import {clearModals} from "@app/modal"
const {url, event} = $props()
type Props = {
url: string
event: TrustedEvent
}
const {url, event}: Props = $props()
const confirm = async () => {
const snapshot = $state.snapshot(event)
await publishDelete({event: snapshot, relays: [url]})
await publishDelete({event, relays: [url]})
clearModals()
}
+1 -1
View File
@@ -10,7 +10,7 @@
}
}
let modal: any = $state()
let modal: any = $state.raw()
const hash = $derived($page.url.hash.slice(1))
const hashIsValid = $derived(Boolean($modals[hash]))