2026-02-03 19:00:13 +00:00
|
|
|
<script lang="ts">
|
2026-02-25 00:09:50 +00:00
|
|
|
import {uniq} from "@welshman/lib"
|
2026-02-03 19:00:13 +00:00
|
|
|
import type {TrustedEvent, EventContent} from "@welshman/util"
|
2026-07-28 16:16:26 +00:00
|
|
|
import {Classified} from "@welshman/domain"
|
2026-09-10 18:21:49 +00:00
|
|
|
import {goto} from "$app/navigation"
|
2026-02-04 00:19:14 +00:00
|
|
|
import Pen2 from "@assets/icons/pen-2.svg?dataurl"
|
2026-02-25 18:01:08 +00:00
|
|
|
import {normalizeTopic} from "@lib/util"
|
2026-02-03 19:00:13 +00:00
|
|
|
import Link from "@lib/components/Link.svelte"
|
2026-02-04 00:19:14 +00:00
|
|
|
import Icon from "@lib/components/Icon.svelte"
|
|
|
|
|
import Button from "@lib/components/Button.svelte"
|
2026-02-03 19:00:13 +00:00
|
|
|
import RoomName from "@app/components/RoomName.svelte"
|
2026-07-28 16:16:26 +00:00
|
|
|
import {publishReaction, retractReaction} from "@app/reactions"
|
2026-02-03 19:00:13 +00:00
|
|
|
import ReactionSummary from "@app/components/ReactionSummary.svelte"
|
2026-08-29 16:19:01 +00:00
|
|
|
import type {FeedContext} from "@app/feeds"
|
2026-02-04 01:09:30 +00:00
|
|
|
import ClassifiedStatus from "@app/components/ClassifiedStatus.svelte"
|
2026-02-03 19:00:13 +00:00
|
|
|
import ThunkStatusOrDeleted from "@app/components/ThunkStatusOrDeleted.svelte"
|
|
|
|
|
import EventActivity from "@app/components/EventActivity.svelte"
|
|
|
|
|
import EventActions from "@app/components/EventActions.svelte"
|
2026-02-04 00:19:14 +00:00
|
|
|
import ClassifiedEdit from "@app/components/ClassifiedEdit.svelte"
|
2026-07-28 16:16:26 +00:00
|
|
|
import {reader, user} from "@app/core"
|
2026-09-10 18:21:49 +00:00
|
|
|
import {makeClassifiedPath, makeSpacePath} from "@app/routes"
|
2026-06-08 21:14:40 +00:00
|
|
|
import {pushModal} from "@app/modal"
|
2026-02-03 19:00:13 +00:00
|
|
|
|
2026-07-28 16:16:26 +00:00
|
|
|
type Props = {
|
2026-02-03 19:00:13 +00:00
|
|
|
url: string
|
|
|
|
|
event: TrustedEvent
|
|
|
|
|
showRoom?: boolean
|
|
|
|
|
showActivity?: boolean
|
2026-08-29 16:19:01 +00:00
|
|
|
context: FeedContext
|
2026-09-10 18:21:49 +00:00
|
|
|
// The grid card lays these out itself, so it opts out of both.
|
|
|
|
|
showTopics?: boolean
|
|
|
|
|
showStatus?: boolean
|
2026-02-03 19:00:13 +00:00
|
|
|
}
|
|
|
|
|
|
2026-09-10 18:21:49 +00:00
|
|
|
const {
|
|
|
|
|
url,
|
|
|
|
|
event,
|
|
|
|
|
showRoom,
|
|
|
|
|
showActivity,
|
|
|
|
|
context,
|
|
|
|
|
showTopics = true,
|
|
|
|
|
showStatus = true,
|
|
|
|
|
}: Props = $props()
|
2026-02-03 19:00:13 +00:00
|
|
|
|
2026-09-24 18:23:21 +00:00
|
|
|
// Editing hands this a new version of the event, so every value is recomputed rather than captured.
|
2026-08-22 20:12:11 +00:00
|
|
|
const classified = $derived(reader(Classified)(event))
|
|
|
|
|
const h = $derived(classified.room())
|
|
|
|
|
const topics = $derived(classified.topics() ?? [])
|
2026-02-03 19:00:13 +00:00
|
|
|
|
2026-02-04 00:19:14 +00:00
|
|
|
const editClassified = () => pushModal(ClassifiedEdit, {url, event})
|
|
|
|
|
|
2026-09-10 18:21:49 +00:00
|
|
|
const filterByTopic = (topic: string) => (e: MouseEvent) => {
|
|
|
|
|
e.stopPropagation()
|
|
|
|
|
e.preventDefault()
|
|
|
|
|
goto(`${makeClassifiedPath(url)}?topic=${encodeURIComponent(normalizeTopic(topic))}`)
|
|
|
|
|
}
|
|
|
|
|
|
2026-07-28 16:16:26 +00:00
|
|
|
const deleteReaction = (reaction: TrustedEvent) => retractReaction(reaction, {url, h})
|
2026-02-03 19:00:13 +00:00
|
|
|
|
2026-07-28 16:16:26 +00:00
|
|
|
const createReaction = (values: EventContent) => publishReaction(event, values, {url, h})
|
2026-02-03 19:00:13 +00:00
|
|
|
</script>
|
|
|
|
|
|
2026-09-10 18:21:49 +00:00
|
|
|
<div class="flex grow flex-wrap items-center justify-end gap-2">
|
|
|
|
|
{#if (h && showRoom) || (showTopics && uniq(topics).length > 0)}
|
|
|
|
|
<div class="flex min-w-0 flex-wrap items-center 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}
|
|
|
|
|
{#if showTopics}
|
|
|
|
|
{#each uniq(topics) as topic (topic)}
|
|
|
|
|
<button
|
|
|
|
|
type="button"
|
|
|
|
|
class="badge badge-neutral badge-sm cursor-pointer font-normal"
|
|
|
|
|
onclick={filterByTopic(topic)}>
|
|
|
|
|
#{normalizeTopic(topic)}
|
|
|
|
|
</button>
|
|
|
|
|
{/each}
|
|
|
|
|
{/if}
|
|
|
|
|
</div>
|
|
|
|
|
<span class="h-6 w-px shrink-0 bg-line"></span>
|
2026-02-03 19:00:13 +00:00
|
|
|
{/if}
|
2026-08-31 17:03:01 +00:00
|
|
|
<ThunkStatusOrDeleted {event} {context}>
|
2026-08-21 15:31:53 +00:00
|
|
|
{#snippet status()}
|
2026-09-10 18:21:49 +00:00
|
|
|
{#if showStatus}
|
|
|
|
|
<ClassifiedStatus {event} />
|
|
|
|
|
{/if}
|
2026-02-04 00:19:14 +00:00
|
|
|
{/snippet}
|
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}
|
2026-09-03 20:13:21 +00:00
|
|
|
<EventActivity {event} {context} />
|
2026-08-21 15:31:53 +00:00
|
|
|
{/if}
|
|
|
|
|
<EventActions {url} {event} noun="Listing">
|
|
|
|
|
{#snippet customActions()}
|
|
|
|
|
{#if event.pubkey === $user.pubkey}
|
|
|
|
|
<li>
|
|
|
|
|
<Button onclick={editClassified}>
|
|
|
|
|
<Icon size={4} icon={Pen2} />
|
|
|
|
|
Edit Listing
|
|
|
|
|
</Button>
|
|
|
|
|
</li>
|
|
|
|
|
{/if}
|
|
|
|
|
{/snippet}
|
|
|
|
|
</EventActions>
|
|
|
|
|
</ThunkStatusOrDeleted>
|
2026-02-03 19:00:13 +00:00
|
|
|
</div>
|