flotilla/src/app/components/ConversationCard.svelte

76 lines
2.7 KiB
Svelte
Raw Normal View History

2025-06-27 16:00:43 +00:00
<script lang="ts">
import {formatTimestamp} from "@welshman/lib"
import type {TrustedEvent} from "@welshman/util"
2025-09-10 22:26:39 +00:00
import AltArrowLeft from "@assets/icons/alt-arrow-left.svg?dataurl"
2025-06-27 16:00:43 +00:00
import Icon from "@lib/components/Icon.svelte"
import Button from "@lib/components/Button.svelte"
2025-10-06 18:23:19 +00:00
import NoteContentMinimal from "@app/components/NoteContentMinimal.svelte"
2025-06-27 16:00:43 +00:00
import ProfileCircle from "@app/components/ProfileCircle.svelte"
import ProfileCircles from "@app/components/ProfileCircles.svelte"
import {goToEvent} from "@app/util/routes"
import {displayChannel} from "@app/core/state"
2025-06-27 16:00:43 +00:00
type Props = {
url: string
2025-10-30 22:33:34 +00:00
h?: string
2025-06-27 16:00:43 +00:00
events: TrustedEvent[]
latest: TrustedEvent
earliest: TrustedEvent
participants: string[]
}
2025-10-30 22:33:34 +00:00
const {url, h, events, latest, earliest, participants}: Props = $props()
2025-06-27 16:00:43 +00:00
</script>
<Button class="card2 bg-alt" onclick={() => goToEvent(earliest)}>
<div class="flex flex-col gap-3">
<div class="flex items-start gap-3">
<ProfileCircle pubkey={earliest.pubkey} size={10} />
<div class="min-w-0 flex-1">
<div class="flex items-center gap-2 text-sm opacity-70">
2025-10-30 22:33:34 +00:00
{#if h}
2025-07-30 23:37:05 +00:00
<span class="truncate font-medium text-blue-400">
2025-10-30 22:33:34 +00:00
#{displayChannel(url, h)}
2025-06-27 16:44:01 +00:00
</span>
<span class="opacity-50">•</span>
{/if}
2025-07-30 23:37:05 +00:00
<span class="text-nowrap">{formatTimestamp(earliest.created_at)}</span>
2025-06-27 16:00:43 +00:00
</div>
2025-10-06 18:23:19 +00:00
<NoteContentMinimal event={earliest} />
2025-06-27 16:00:43 +00:00
</div>
</div>
<div class="ml-13 flex items-center justify-between">
<div class="flex gap-1">
2025-09-10 22:26:39 +00:00
<Icon icon={AltArrowLeft} />
2025-06-27 16:00:43 +00:00
<span class="text-sm opacity-70">
{events.length}
{events.length === 1 ? "message" : "messages"}
</span>
</div>
<div class="flex gap-2">
<ProfileCircles pubkeys={participants} size={6} />
<span class="text-sm opacity-70">
{participants.length}
{participants.length === 1 ? "participant" : "participants"}
</span>
</div>
</div>
{#if latest !== earliest}
<Button class="card2 bg-alt" onclick={() => goToEvent(latest)}>
<div class="flex flex-col gap-2">
<div class="flex items-center justify-between">
<div class="flex items-center gap-2 text-sm opacity-70">
<ProfileCircle pubkey={latest.pubkey} size={5} />
<span class="font-medium">Latest reply:</span>
</div>
<span class="text-xs opacity-50">
{formatTimestamp(latest.created_at)}
</span>
</div>
2025-10-06 18:23:19 +00:00
<NoteContentMinimal event={latest} />
2025-06-27 16:00:43 +00:00
</div>
</Button>
{/if}
</div>
</Button>