flotilla/src/app/components/CommentActions.svelte

48 lines
1.6 KiB
Svelte
Raw Normal View History

2025-06-13 17:14:12 +00:00
<script lang="ts">
import type {TrustedEvent, EventContent} from "@welshman/util"
2026-07-28 16:16:26 +00:00
import {tagSpec, tagValue} from "@welshman/util"
2025-06-13 17:14:12 +00:00
import ReactionSummary from "@app/components/ReactionSummary.svelte"
import type {FeedContext} from "@app/feeds"
2026-07-28 16:16:26 +00:00
import {publishReaction, retractReaction} from "@app/reactions"
2025-06-13 17:14:12 +00:00
import ThunkStatusOrDeleted from "@app/components/ThunkStatusOrDeleted.svelte"
import EventActivity from "@app/components/EventActivity.svelte"
import EventActions from "@app/components/EventActions.svelte"
2026-06-08 21:14:40 +00:00
import {makeSpacePath} from "@app/routes"
2025-06-13 17:14:12 +00:00
2026-07-28 16:16:26 +00:00
type Props = {
2026-02-03 19:00:13 +00:00
url: string
event: TrustedEvent
2026-08-17 15:42:14 +00:00
segment?: string
2025-06-13 17:14:12 +00:00
showActivity?: boolean
context: FeedContext
2025-06-13 17:14:12 +00:00
}
const {url, event, segment, showActivity = false, context}: Props = $props()
2025-06-13 17:14:12 +00:00
2026-07-28 16:16:26 +00:00
const h = tagValue(tagSpec("h"), event.tags)
2026-08-17 15:42:14 +00:00
const path = segment && makeSpacePath(url, segment, event.id)
2025-06-13 17:14:12 +00:00
2026-07-28 16:16:26 +00:00
const deleteReaction = (reaction: TrustedEvent) => retractReaction(reaction, {url, h})
2025-06-13 17:14:12 +00:00
2026-07-28 16:16:26 +00:00
const createReaction = (values: EventContent) => publishReaction(event, values, {url, h})
2025-06-13 17:14:12 +00:00
</script>
<div class="flex flex-wrap items-center justify-between gap-2">
2026-04-07 21:53:19 +00:00
<div class="flex grow flex-wrap justify-end gap-2">
2026-08-31 17:03:01 +00:00
<ThunkStatusOrDeleted {event} {context}>
<ReactionSummary
{url}
{event}
{context}
{deleteReaction}
{createReaction}
reactionClass="tip-left" />
2026-08-21 15:31:53 +00:00
{#if showActivity && path}
<EventActivity {path} {event} {context} />
2026-08-21 15:31:53 +00:00
{/if}
<EventActions {url} {event} noun="Comment" />
</ThunkStatusOrDeleted>
2025-06-13 17:14:12 +00:00
</div>
</div>