2026-08-17 15:42:14 +00:00
|
|
|
<script lang="ts">
|
|
|
|
|
import {uniq} from "@welshman/lib"
|
|
|
|
|
import type {TrustedEvent, EventContent} from "@welshman/util"
|
|
|
|
|
import {getAddress} from "@welshman/util"
|
|
|
|
|
import {Article} from "@welshman/domain"
|
|
|
|
|
import Link from "@lib/components/Link.svelte"
|
|
|
|
|
import RoomName from "@app/components/RoomName.svelte"
|
|
|
|
|
import {publishReaction, retractReaction} from "@app/reactions"
|
|
|
|
|
import ReactionSummary from "@app/components/ReactionSummary.svelte"
|
2026-08-29 16:19:01 +00:00
|
|
|
import type {FeedContext} from "@app/feeds"
|
2026-08-17 15:42:14 +00:00
|
|
|
import ThunkStatusOrDeleted from "@app/components/ThunkStatusOrDeleted.svelte"
|
|
|
|
|
import EventActivity from "@app/components/EventActivity.svelte"
|
|
|
|
|
import EventActions from "@app/components/EventActions.svelte"
|
|
|
|
|
import {reader} from "@app/core"
|
|
|
|
|
import {makeArticlePath, makeSpacePath} from "@app/routes"
|
|
|
|
|
|
|
|
|
|
type Props = {
|
|
|
|
|
url: string
|
|
|
|
|
event: TrustedEvent
|
|
|
|
|
showRoom?: boolean
|
|
|
|
|
showActivity?: boolean
|
2026-08-29 16:19:01 +00:00
|
|
|
context: FeedContext
|
2026-08-17 15:42:14 +00:00
|
|
|
}
|
|
|
|
|
|
2026-08-29 16:19:01 +00:00
|
|
|
const {url, event, showRoom, showActivity, context}: Props = $props()
|
2026-08-17 15:42:14 +00:00
|
|
|
|
2026-08-22 20:12:11 +00:00
|
|
|
const article = $derived(reader(Article)(event))
|
|
|
|
|
const h = $derived(article.room())
|
|
|
|
|
const topics = $derived(article.topics())
|
|
|
|
|
const path = $derived(makeArticlePath(url, getAddress(event)))
|
2026-08-17 15:42:14 +00:00
|
|
|
|
|
|
|
|
const deleteReaction = (reaction: TrustedEvent) => retractReaction(reaction, {url, h})
|
|
|
|
|
|
|
|
|
|
const createReaction = (values: EventContent) => publishReaction(event, values, {url, h})
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<div class="flex grow flex-wrap justify-end gap-2">
|
|
|
|
|
{#if h && showRoom}
|
|
|
|
|
<Link href={makeSpacePath(url, h)} class="button button-neutral button-xs rounded-full">
|
|
|
|
|
Posted in #<RoomName {h} {url} />
|
|
|
|
|
</Link>
|
|
|
|
|
{/if}
|
|
|
|
|
<div class="flex min-w-0 flex-wrap gap-2">
|
|
|
|
|
{#each uniq(topics) as topic (topic)}
|
|
|
|
|
<button type="button" class="button button-xs rounded-full font-normal">
|
|
|
|
|
#{topic}
|
|
|
|
|
</button>
|
|
|
|
|
{/each}
|
|
|
|
|
</div>
|
2026-08-21 15:31:53 +00:00
|
|
|
<ThunkStatusOrDeleted {event}>
|
2026-08-29 16:19:01 +00:00
|
|
|
<ReactionSummary
|
|
|
|
|
{url}
|
|
|
|
|
{event}
|
|
|
|
|
{context}
|
|
|
|
|
{deleteReaction}
|
|
|
|
|
{createReaction}
|
|
|
|
|
reactionClass="tip-left" />
|
2026-08-21 15:31:53 +00:00
|
|
|
{#if showActivity}
|
|
|
|
|
<EventActivity {url} {path} {event} />
|
|
|
|
|
{/if}
|
|
|
|
|
<EventActions {url} {event} noun="Article" />
|
|
|
|
|
</ThunkStatusOrDeleted>
|
2026-08-17 15:42:14 +00:00
|
|
|
</div>
|