mirror of
https://github.com/coracle-social/flotilla.git
synced 2025-12-10 19:07:06 +00:00
Fix some state stuff, snapshot things in the right places
This commit is contained in:
@@ -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})
|
||||
|
||||
|
||||
@@ -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})
|
||||
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
|
||||
@@ -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]))
|
||||
|
||||
|
||||
@@ -322,7 +322,9 @@ export const listenForNotifications = () => {
|
||||
relays: [url],
|
||||
filters: [
|
||||
{kinds: [THREAD], limit: 1},
|
||||
{kinds: [EVENT_TIME], limit: 1},
|
||||
{kinds: [COMMENT], "#K": [String(THREAD)], limit: 1},
|
||||
{kinds: [COMMENT], "#K": [String(EVENT_TIME)], limit: 1},
|
||||
...rooms.map(room => ({kinds: [MESSAGE], "#h": [room], limit: 1})),
|
||||
],
|
||||
})
|
||||
@@ -331,8 +333,8 @@ export const listenForNotifications = () => {
|
||||
subscribe({
|
||||
relays: [url],
|
||||
filters: [
|
||||
{kinds: [THREAD], since: now()},
|
||||
{kinds: [COMMENT], "#K": [String(THREAD)], since: now()},
|
||||
{kinds: [THREAD, EVENT_TIME], since: now()},
|
||||
{kinds: [COMMENT], "#K": [String(THREAD), String(EVENT_TIME)], since: now()},
|
||||
...rooms.map(room => ({kinds: [MESSAGE], "#h": [room], since: now()})),
|
||||
],
|
||||
}),
|
||||
|
||||
@@ -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">
|
||||
|
||||
Reference in New Issue
Block a user