flotilla/src/app/components/RecentConversation.svelte

59 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-07-28 16:16:26 +00:00
import {tagValue, tagSpec} from "@welshman/util"
2026-02-02 23:36:50 +00:00
import ChatRoundDots from "@assets/icons/chat-round-dots.svg?dataurl"
2026-02-03 17:49:44 +00:00
import AltArrowRight from "@assets/icons/alt-arrow-right.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"
2026-06-08 21:14:40 +00:00
import {makeRoomPath, makeSpaceChatPath} from "@app/routes"
2025-06-27 16:00:43 +00:00
type Props = {
url: string
2026-02-03 17:49:44 +00:00
event: TrustedEvent
2026-02-02 23:36:50 +00:00
count: number
2025-06-27 16:00:43 +00:00
}
2026-02-03 17:49:44 +00:00
const {url, event, count}: Props = $props()
2026-02-02 23:36:50 +00:00
2026-07-28 16:16:26 +00:00
const h = tagValue(tagSpec("h"), event.tags)
2026-02-02 23:36:50 +00:00
2026-02-03 17:49:44 +00:00
const onClick = () => goto(h ? makeRoomPath(url, h) : makeSpaceChatPath(url))
2025-06-27 16:00:43 +00:00
</script>
<Button class="cv card card-interactive" onclick={onClick}>
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">
2026-02-03 17:49:44 +00:00
{formatTimestamp(event.created_at)}
2026-02-02 23:36:50 +00:00
</span>
</div>
2025-06-27 16:00:43 +00:00
<div class="flex items-start gap-3">
2026-02-03 17:49:44 +00:00
<ProfileCircle pubkey={event.pubkey} size={10} />
2025-06-27 16:00:43 +00:00
<div class="min-w-0 flex-1">
2026-02-03 17:49:44 +00:00
<NoteContentMinimal {event} />
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}
2026-02-03 17:49:44 +00:00
recent messages{count === 1 ? "" : "s"}
2026-02-02 23:36:50 +00:00
</span>
<Button class="button button-primary button-xs button-pill" onclick={onClick}>
2026-02-03 17:49:44 +00:00
View Conversation
<Icon icon={AltArrowRight} />
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>