2026-06-17 16:08:58 +00:00
|
|
|
<script lang="ts">
|
|
|
|
|
import {formatTimestamp, max} from "@welshman/lib"
|
|
|
|
|
import type {TrustedEvent} from "@welshman/util"
|
|
|
|
|
import {COMMENT, getTagValue} from "@welshman/util"
|
2026-06-24 18:19:13 +00:00
|
|
|
import {goto} from "$app/navigation"
|
2026-06-17 16:08:58 +00:00
|
|
|
import ProfileCircle from "@app/components/ProfileCircle.svelte"
|
|
|
|
|
import ProfileName from "@app/components/ProfileName.svelte"
|
|
|
|
|
import {deriveEventsForUrl} from "@app/repository"
|
|
|
|
|
import {makeThreadPath} from "@app/routes"
|
|
|
|
|
|
|
|
|
|
type Props = {
|
|
|
|
|
url: string
|
|
|
|
|
event: TrustedEvent
|
2026-07-15 21:23:43 +00:00
|
|
|
mobile?: boolean
|
2026-06-17 16:08:58 +00:00
|
|
|
}
|
|
|
|
|
|
2026-07-15 21:23:43 +00:00
|
|
|
const {url, event, mobile = false}: Props = $props()
|
2026-06-17 16:08:58 +00:00
|
|
|
|
|
|
|
|
const filters = [{kinds: [COMMENT], "#E": [event.id]}]
|
|
|
|
|
const replies = deriveEventsForUrl(url, filters)
|
|
|
|
|
const replyCount = $derived($replies.length)
|
|
|
|
|
const lastActive = $derived(max([...$replies, event].map(e => e.created_at)))
|
|
|
|
|
const title = getTagValue("title", event.tags)
|
2026-06-24 18:19:13 +00:00
|
|
|
const path = makeThreadPath(url, event.id)
|
2026-07-15 21:23:43 +00:00
|
|
|
|
2026-06-24 18:19:13 +00:00
|
|
|
const goToThread = () => goto(path)
|
2026-06-17 16:08:58 +00:00
|
|
|
</script>
|
|
|
|
|
|
2026-07-15 21:23:43 +00:00
|
|
|
{#if mobile}
|
|
|
|
|
<button
|
|
|
|
|
type="button"
|
|
|
|
|
class="hover:bg-surface-less flex w-full flex-col gap-2 border-b border-solid border-line px-4 py-3 text-left text-sm transition-colors"
|
|
|
|
|
onclick={goToThread}>
|
|
|
|
|
<p class="truncate font-medium">{title || "Untitled thread"}</p>
|
|
|
|
|
<div class="text-content-muted flex flex-wrap items-center gap-x-3 gap-y-1 text-xs">
|
|
|
|
|
<span class="flex min-w-0 items-center gap-1.5">
|
|
|
|
|
<ProfileCircle pubkey={event.pubkey} {url} size={4} />
|
|
|
|
|
<span class="truncate">
|
|
|
|
|
<ProfileName pubkey={event.pubkey} {url} />
|
|
|
|
|
</span>
|
|
|
|
|
</span>
|
|
|
|
|
<span>{replyCount} {replyCount === 1 ? "reply" : "replies"}</span>
|
|
|
|
|
<span>{formatTimestamp(lastActive)}</span>
|
|
|
|
|
</div>
|
|
|
|
|
</button>
|
|
|
|
|
{:else}
|
|
|
|
|
<tr
|
|
|
|
|
class="hover:bg-surface-less cursor-pointer border-b border-solid border-line text-sm transition-colors"
|
|
|
|
|
onclick={goToThread}>
|
|
|
|
|
<td class="max-w-0 truncate px-4 py-3 align-top">
|
|
|
|
|
{title || "Untitled thread"}
|
|
|
|
|
</td>
|
|
|
|
|
<td class="w-32 px-4 py-3 align-middle">
|
|
|
|
|
<div class="flex min-w-0 items-center gap-2">
|
|
|
|
|
<ProfileCircle pubkey={event.pubkey} {url} size={5} />
|
|
|
|
|
<span class="min-w-0 truncate">
|
|
|
|
|
<ProfileName pubkey={event.pubkey} {url} />
|
|
|
|
|
</span>
|
|
|
|
|
</div>
|
|
|
|
|
</td>
|
|
|
|
|
<td class="w-20 px-4 py-3 text-center align-middle">
|
|
|
|
|
{replyCount}
|
|
|
|
|
</td>
|
|
|
|
|
<td class="w-32 whitespace-nowrap px-4 py-3 text-right align-middle">
|
|
|
|
|
{formatTimestamp(lastActive)}
|
|
|
|
|
</td>
|
|
|
|
|
</tr>
|
|
|
|
|
{/if}
|