flotilla/src/app/components/NoteItem.svelte

41 lines
1.5 KiB
Svelte
Raw Normal View History

2024-10-31 19:24:40 +00:00
<script lang="ts">
import type {NativeEmoji} from "emoji-picker-element/shared"
2025-05-12 22:10:24 +00:00
import type {TrustedEvent, EventContent} 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"
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, canEnforceNip70} from "@app/core/commands"
2024-10-31 19:24:40 +00:00
const {url, event} = $props()
2024-10-31 19:24:40 +00:00
const shouldProtect = canEnforceNip70(url)
const deleteReaction = async (event: TrustedEvent) =>
publishDelete({relays: [url], event, protect: await shouldProtect})
2024-10-31 19:24:40 +00:00
const createReaction = async (template: EventContent) =>
publishReaction({...template, event, relays: [url], protect: await shouldProtect})
2024-10-31 19:24:40 +00:00
const onEmoji = async (emoji: NativeEmoji) =>
publishReaction({
event,
content: emoji.unicode,
relays: [url],
protect: await shouldProtect,
})
2024-10-31 19:24:40 +00:00
</script>
2025-04-15 18:03:27 +00:00
<NoteCard {event} {url} 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-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>
</div>
</NoteCard>