forked from coracle/flotilla
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 {publishReaction} from "@app/commands"
|
||||||
import {pushModal} from "@app/modal"
|
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) => {
|
const onEmoji = ((event: TrustedEvent, url: string, emoji: NativeEmoji) => {
|
||||||
history.back()
|
history.back()
|
||||||
publishReaction({event, relays: [url], content: emoji.unicode})
|
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})
|
const showEmojiPicker = () => pushModal(EmojiPicker, {onClick: onEmoji}, {replaceState: true})
|
||||||
|
|
||||||
|
|||||||
@@ -42,8 +42,6 @@
|
|||||||
const others = remove($pubkey!, pubkeys)
|
const others = remove($pubkey!, pubkeys)
|
||||||
const missingInboxes = $derived(pubkeys.filter(pk => !$inboxRelaySelectionsByPubkey.has(pk)))
|
const missingInboxes = $derived(pubkeys.filter(pk => !$inboxRelaySelectionsByPubkey.has(pk)))
|
||||||
|
|
||||||
const assertEvent = (e: any) => e as TrustedEvent
|
|
||||||
|
|
||||||
const showMembers = () =>
|
const showMembers = () =>
|
||||||
pushModal(ProfileList, {pubkeys: others, title: `People in this conversation`})
|
pushModal(ProfileList, {pubkeys: others, title: `People in this conversation`})
|
||||||
|
|
||||||
@@ -196,7 +194,11 @@
|
|||||||
{#if type === "date"}
|
{#if type === "date"}
|
||||||
<Divider>{value}</Divider>
|
<Divider>{value}</Divider>
|
||||||
{:else}
|
{:else}
|
||||||
<ChatMessage event={assertEvent(value)} {pubkeys} {showPubkey} {replyTo} />
|
<ChatMessage
|
||||||
|
event={$state.snapshot(value as TrustedEvent)}
|
||||||
|
{pubkeys}
|
||||||
|
{showPubkey}
|
||||||
|
{replyTo} />
|
||||||
{/if}
|
{/if}
|
||||||
{/each}
|
{/each}
|
||||||
<p
|
<p
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
const onEmoji = ((event: TrustedEvent, emoji: NativeEmoji) => {
|
const onEmoji = ((event: TrustedEvent, emoji: NativeEmoji) => {
|
||||||
history.back()
|
history.back()
|
||||||
sendWrapped({template: makeReaction({event, content: emoji.unicode}), pubkeys})
|
sendWrapped({template: makeReaction({event, content: emoji.unicode}), pubkeys})
|
||||||
}).bind(undefined, $state.snapshot(event))
|
}).bind(undefined, event)
|
||||||
|
|
||||||
const showEmojiPicker = () => pushModal(EmojiPicker, {onClick: onEmoji}, {replaceState: true})
|
const showEmojiPicker = () => pushModal(EmojiPicker, {onClick: onEmoji}, {replaceState: true})
|
||||||
|
|
||||||
|
|||||||
@@ -1,14 +1,18 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import type {TrustedEvent} from "@welshman/util"
|
||||||
import Confirm from "@lib/components/Confirm.svelte"
|
import Confirm from "@lib/components/Confirm.svelte"
|
||||||
import {publishDelete} from "@app/commands"
|
import {publishDelete} from "@app/commands"
|
||||||
import {clearModals} from "@app/modal"
|
import {clearModals} from "@app/modal"
|
||||||
|
|
||||||
const {url, event} = $props()
|
type Props = {
|
||||||
|
url: string
|
||||||
|
event: TrustedEvent
|
||||||
|
}
|
||||||
|
|
||||||
|
const {url, event}: Props = $props()
|
||||||
|
|
||||||
const confirm = async () => {
|
const confirm = async () => {
|
||||||
const snapshot = $state.snapshot(event)
|
await publishDelete({event, relays: [url]})
|
||||||
|
|
||||||
await publishDelete({event: snapshot, relays: [url]})
|
|
||||||
|
|
||||||
clearModals()
|
clearModals()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let modal: any = $state()
|
let modal: any = $state.raw()
|
||||||
const hash = $derived($page.url.hash.slice(1))
|
const hash = $derived($page.url.hash.slice(1))
|
||||||
const hashIsValid = $derived(Boolean($modals[hash]))
|
const hashIsValid = $derived(Boolean($modals[hash]))
|
||||||
|
|
||||||
|
|||||||
+4
-2
@@ -322,7 +322,9 @@ export const listenForNotifications = () => {
|
|||||||
relays: [url],
|
relays: [url],
|
||||||
filters: [
|
filters: [
|
||||||
{kinds: [THREAD], limit: 1},
|
{kinds: [THREAD], limit: 1},
|
||||||
|
{kinds: [EVENT_TIME], limit: 1},
|
||||||
{kinds: [COMMENT], "#K": [String(THREAD)], 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})),
|
...rooms.map(room => ({kinds: [MESSAGE], "#h": [room], limit: 1})),
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
@@ -331,8 +333,8 @@ export const listenForNotifications = () => {
|
|||||||
subscribe({
|
subscribe({
|
||||||
relays: [url],
|
relays: [url],
|
||||||
filters: [
|
filters: [
|
||||||
{kinds: [THREAD], since: now()},
|
{kinds: [THREAD, EVENT_TIME], since: now()},
|
||||||
{kinds: [COMMENT], "#K": [String(THREAD)], since: now()},
|
{kinds: [COMMENT], "#K": [String(THREAD), String(EVENT_TIME)], since: now()},
|
||||||
...rooms.map(room => ({kinds: [MESSAGE], "#h": [room], since: now()})),
|
...rooms.map(room => ({kinds: [MESSAGE], "#h": [room], since: now()})),
|
||||||
],
|
],
|
||||||
}),
|
}),
|
||||||
|
|||||||
@@ -46,8 +46,6 @@
|
|||||||
const filter = {kinds: [MESSAGE], "#h": [room]}
|
const filter = {kinds: [MESSAGE], "#h": [room]}
|
||||||
const relay = deriveRelay(url)
|
const relay = deriveRelay(url)
|
||||||
|
|
||||||
const assertEvent = (e: any) => e as TrustedEvent
|
|
||||||
|
|
||||||
const joinRoom = async () => {
|
const joinRoom = async () => {
|
||||||
if (hasNip29($relay)) {
|
if (hasNip29($relay)) {
|
||||||
joiningRoom = true
|
joiningRoom = true
|
||||||
@@ -275,7 +273,12 @@
|
|||||||
<Divider>{value}</Divider>
|
<Divider>{value}</Divider>
|
||||||
{:else}
|
{:else}
|
||||||
<div in:slide class:-mt-1={!showPubkey}>
|
<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>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
{/each}
|
{/each}
|
||||||
|
|||||||
@@ -42,8 +42,6 @@
|
|||||||
return sortBy(e => -max([scores.get(e.id), e.created_at]), threads)
|
return sortBy(e => -max([scores.get(e.id), e.created_at]), threads)
|
||||||
})
|
})
|
||||||
|
|
||||||
$inspect({threads, comments, events})
|
|
||||||
|
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
const {cleanup} = makeFeed({
|
const {cleanup} = makeFeed({
|
||||||
element: element!,
|
element: element!,
|
||||||
@@ -98,7 +96,7 @@
|
|||||||
<div class="flex flex-grow flex-col gap-2 overflow-auto p-2">
|
<div class="flex flex-grow flex-col gap-2 overflow-auto p-2">
|
||||||
{#each events as event (event.id)}
|
{#each events as event (event.id)}
|
||||||
<div in:fly>
|
<div in:fly>
|
||||||
<ThreadItem {url} {event} />
|
<ThreadItem {url} event={$state.snapshot(event)} />
|
||||||
</div>
|
</div>
|
||||||
{/each}
|
{/each}
|
||||||
<p class="flex h-10 items-center justify-center py-20">
|
<p class="flex h-10 items-center justify-center py-20">
|
||||||
|
|||||||
Reference in New Issue
Block a user