2024-10-31 19:24:40 +00:00
|
|
|
<script lang="ts">
|
2026-02-03 17:49:44 +00:00
|
|
|
import type {Snippet} from "svelte"
|
2024-10-31 19:24:40 +00:00
|
|
|
import type {NativeEmoji} from "emoji-picker-element/shared"
|
2025-05-12 22:10:24 +00:00
|
|
|
import type {TrustedEvent, EventContent} from "@welshman/util"
|
2026-07-28 16:16:26 +00:00
|
|
|
import {seen} from "@welshman/util"
|
2025-09-10 22:26:39 +00:00
|
|
|
import SmileCircle from "@assets/icons/smile-circle.svg?dataurl"
|
2024-10-31 19:24:40 +00:00
|
|
|
import Icon from "@lib/components/Icon.svelte"
|
|
|
|
|
import EmojiButton from "@lib/components/EmojiButton.svelte"
|
2025-02-11 23:37:50 +00:00
|
|
|
import NoteContent from "@app/components/NoteContent.svelte"
|
2026-07-28 16:16:26 +00:00
|
|
|
import {publishReaction, retractReaction} from "@app/reactions"
|
2024-10-31 19:24:40 +00:00
|
|
|
import NoteCard from "@app/components/NoteCard.svelte"
|
|
|
|
|
import ReactionSummary from "@app/components/ReactionSummary.svelte"
|
2026-07-28 16:16:26 +00:00
|
|
|
import {router} from "@app/core"
|
2024-10-31 19:24:40 +00:00
|
|
|
|
2026-02-03 17:49:44 +00:00
|
|
|
type Props = {
|
|
|
|
|
event: TrustedEvent
|
|
|
|
|
children?: Snippet
|
2026-02-13 21:05:17 +00:00
|
|
|
url?: string
|
2026-02-03 17:49:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const {url, event, children}: Props = $props()
|
2024-10-31 19:24:40 +00:00
|
|
|
|
2026-07-28 16:16:26 +00:00
|
|
|
const getRelays = () => (url ? [url] : $router.resolver.relays([seen(event)]))
|
2026-02-13 21:05:17 +00:00
|
|
|
|
2026-07-28 16:16:26 +00:00
|
|
|
const deleteReaction = async (reaction: TrustedEvent) =>
|
|
|
|
|
retractReaction(reaction, {url, urls: await getRelays()})
|
2025-08-19 21:03:04 +00:00
|
|
|
|
2026-07-28 16:16:26 +00:00
|
|
|
const createReaction = async (values: EventContent) =>
|
|
|
|
|
publishReaction(event, values, {url, urls: await getRelays()})
|
2024-10-31 19:24:40 +00:00
|
|
|
|
2026-07-28 16:16:26 +00:00
|
|
|
const onEmoji = (emoji: NativeEmoji) => createReaction({content: emoji.unicode, tags: []})
|
2024-10-31 19:24:40 +00:00
|
|
|
</script>
|
|
|
|
|
|
2026-06-24 20:56:53 +00:00
|
|
|
<NoteCard {event} {url} class="cv card card-interactive">
|
2025-02-11 23:37:50 +00:00
|
|
|
<NoteContent {event} expandMode="inline" />
|
2024-10-31 19:24:40 +00:00
|
|
|
<div class="flex w-full justify-between gap-2">
|
2026-06-24 20:56:53 +00:00
|
|
|
<ReactionSummary {url} {event} {deleteReaction} {createReaction} reactionClass="tip-right">
|
|
|
|
|
<EmojiButton {onEmoji} class="button button-neutral button-xs h-[26px] rounded-2xl">
|
2025-09-10 22:26:39 +00:00
|
|
|
<Icon icon={SmileCircle} size={4} />
|
2024-10-31 19:24:40 +00:00
|
|
|
</EmojiButton>
|
|
|
|
|
</ReactionSummary>
|
2026-02-03 17:49:44 +00:00
|
|
|
{@render children?.()}
|
2024-10-31 19:24:40 +00:00
|
|
|
</div>
|
|
|
|
|
</NoteCard>
|