flotilla/src/app/components/ConversationCard.svelte

64 lines
2 KiB
Svelte
Raw Normal View History

2025-06-27 16:00:43 +00:00
<script lang="ts">
2026-02-02 23:36:50 +00:00
import {goto} from "$app/navigation"
2025-06-27 16:00:43 +00:00
import {formatTimestamp} from "@welshman/lib"
import type {TrustedEvent} from "@welshman/util"
2026-02-02 23:36:50 +00:00
import ChatRoundDots from "@assets/icons/chat-round-dots.svg?dataurl"
import Reply from "@assets/icons/reply.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"
2026-02-02 23:36:50 +00:00
import RoomNameWithImage from "@app/components/RoomNameWithImage.svelte"
import {makeRoomPath, makeSpaceChatPath} from "@app/util/routes"
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
latest: TrustedEvent
2026-02-02 23:36:50 +00:00
count: number
2025-06-27 16:00:43 +00:00
}
2026-02-02 23:36:50 +00:00
const {url, h, latest, count}: Props = $props()
const navigateToRoom = () => {
goto(h ? makeRoomPath(url, h) : makeSpaceChatPath(url))
}
const handleReplyClick = (e: Event) => {
e.stopPropagation()
navigateToRoom()
}
2025-06-27 16:00:43 +00:00
</script>
2026-02-02 23:36:50 +00:00
<Button class="card2 bg-alt shadow-md" onclick={navigateToRoom}>
2025-06-27 16:00:43 +00:00
<div class="flex flex-col gap-3">
2026-02-02 23:36:50 +00:00
<div class="flex items-center gap-2 text-sm">
{#if h}
<RoomNameWithImage {url} {h} class="font-semibold" />
{:else}
<Icon icon={ChatRoundDots} class="h-6 w-6 opacity-50" />
<span class="truncate font-semibold">Chat</span>
{/if}
<span class="ml-auto text-nowrap opacity-50">
{formatTimestamp(latest.created_at)}
</span>
</div>
2025-06-27 16:00:43 +00:00
<div class="flex items-start gap-3">
2026-02-02 23:36:50 +00:00
<ProfileCircle pubkey={latest.pubkey} size={10} />
2025-06-27 16:00:43 +00:00
<div class="min-w-0 flex-1">
2026-02-02 23:36:50 +00:00
<NoteContentMinimal event={latest} />
2025-06-27 16:00:43 +00:00
</div>
</div>
2026-02-02 23:36:50 +00:00
<div class="flex items-center justify-between gap-2 text-xs">
<span class="opacity-50">
{count}
{count === 1 ? "message" : "messages"} this week
</span>
<Button class="btn btn-sm btn-primary" onclick={handleReplyClick}>
<Icon icon={Reply} />
Reply
2025-06-27 16:00:43 +00:00
</Button>
2026-02-02 23:36:50 +00:00
</div>
2025-06-27 16:00:43 +00:00
</div>
</Button>