2024-10-31 19:24:40 +00:00
|
|
|
<script lang="ts">
|
|
|
|
|
import type {NativeEmoji} from "emoji-picker-element/shared"
|
|
|
|
|
import type {TrustedEvent} from "@welshman/util"
|
2024-11-15 22:03:54 +00:00
|
|
|
import {pubkey} from "@welshman/app"
|
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"
|
|
|
|
|
import {publishDelete, publishReaction} from "@app/commands"
|
|
|
|
|
|
2025-02-04 01:21:46 +00:00
|
|
|
const {url, event} = $props()
|
2024-10-31 19:24:40 +00:00
|
|
|
|
|
|
|
|
const onReactionClick = (content: string, events: TrustedEvent[]) => {
|
|
|
|
|
const reaction = events.find(e => e.pubkey === $pubkey)
|
|
|
|
|
|
|
|
|
|
if (reaction) {
|
|
|
|
|
publishDelete({relays: [url], event: reaction})
|
|
|
|
|
} else {
|
2024-12-16 21:33:34 +00:00
|
|
|
publishReaction({event, content, relays: [url]})
|
2024-10-31 19:24:40 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const onEmoji = (emoji: NativeEmoji) =>
|
2024-12-16 21:33:34 +00:00
|
|
|
publishReaction({event, content: emoji.unicode, relays: [url]})
|
2024-10-31 19:24:40 +00:00
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<NoteCard {event} class="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-01-15 01:23:27 +00:00
|
|
|
<ReactionSummary {url} {event} {onReactionClick} reactionClass="tooltip-right">
|
2024-10-31 19:24:40 +00:00
|
|
|
<EmojiButton {onEmoji} class="btn btn-neutral btn-xs h-[26px] rounded-box">
|
|
|
|
|
<Icon icon="smile-circle" size={4} />
|
|
|
|
|
</EmojiButton>
|
|
|
|
|
</ReactionSummary>
|
|
|
|
|
</div>
|
|
|
|
|
</NoteCard>
|