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-02-13 21:05:17 +00:00
|
|
|
import {Router} from "@welshman/router"
|
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"
|
2024-10-31 19:24:40 +00:00
|
|
|
import NoteCard from "@app/components/NoteCard.svelte"
|
|
|
|
|
import ReactionSummary from "@app/components/ReactionSummary.svelte"
|
2026-06-08 22:33:38 +00:00
|
|
|
import {publishDelete} from "@app/deletes"
|
|
|
|
|
import {publishReaction} from "@app/reactions"
|
|
|
|
|
import {canEnforceNip70} from "@app/relays"
|
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-02-13 21:05:17 +00:00
|
|
|
const relays = url ? [url] : Router.get().Event(event).getUrls()
|
|
|
|
|
|
|
|
|
|
const shouldProtect = url ? canEnforceNip70(url) : Promise.resolve(false)
|
2025-08-19 21:03:04 +00:00
|
|
|
|
2025-07-30 23:30:03 +00:00
|
|
|
const deleteReaction = async (event: TrustedEvent) =>
|
2026-02-13 21:05:17 +00:00
|
|
|
publishDelete({relays, event, protect: await shouldProtect})
|
2024-10-31 19:24:40 +00:00
|
|
|
|
2025-07-30 23:30:03 +00:00
|
|
|
const createReaction = async (template: EventContent) =>
|
2026-02-13 21:05:17 +00:00
|
|
|
publishReaction({...template, event, relays, protect: await shouldProtect})
|
2024-10-31 19:24:40 +00:00
|
|
|
|
2025-07-30 23:30:03 +00:00
|
|
|
const onEmoji = async (emoji: NativeEmoji) =>
|
|
|
|
|
publishReaction({
|
|
|
|
|
event,
|
2026-02-13 21:05:17 +00:00
|
|
|
relays,
|
2025-07-30 23:30:03 +00:00
|
|
|
content: emoji.unicode,
|
2025-08-19 21:03:04 +00:00
|
|
|
protect: await shouldProtect,
|
2025-07-30 23:30:03 +00:00
|
|
|
})
|
2024-10-31 19:24:40 +00:00
|
|
|
</script>
|
|
|
|
|
|
2026-02-19 00:37:55 +00:00
|
|
|
<NoteCard {event} {url} class="cv card2 bg-alt">
|
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">
|
2025-05-12 22:10:24 +00:00
|
|
|
<ReactionSummary {url} {event} {deleteReaction} {createReaction} reactionClass="tooltip-right">
|
2024-10-31 19:24:40 +00:00
|
|
|
<EmojiButton {onEmoji} class="btn btn-neutral btn-xs h-[26px] rounded-box">
|
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>
|