flotilla/src/app/components/PeopleItem.svelte

49 lines
1.6 KiB
Svelte
Raw Normal View History

2024-10-01 21:55:33 +00:00
<script lang="ts">
2024-10-08 18:39:16 +00:00
import {onMount} from "svelte"
import type {Filter} from "@welshman/util"
import {deriveEvents} from "@welshman/store"
2025-04-09 22:32:18 +00:00
import {load} from "@welshman/net"
import {Router, repository, loadRelaySelections, formatTimestampRelative} from "@welshman/app"
import Icon from "@lib/components/Icon.svelte"
import Link from "@lib/components/Link.svelte"
2024-10-01 21:55:33 +00:00
import Profile from "@app/components/Profile.svelte"
import ProfileInfo from "@app/components/ProfileInfo.svelte"
import {makeChatPath} from "@app/routes"
2024-10-01 21:55:33 +00:00
const {pubkey} = $props()
2024-10-01 21:55:33 +00:00
2025-01-17 23:01:05 +00:00
const filters: Filter[] = [{authors: [pubkey], limit: 1}]
2024-10-01 21:55:33 +00:00
const events = deriveEvents(repository, {filters})
onMount(async () => {
// Make sure we have their relay selections before we load their posts
await loadRelaySelections(pubkey)
// Load at least one note, regardless of time frame
load({
2024-10-24 23:44:31 +00:00
filters: [{authors: [pubkey], limit: 1}],
2025-04-09 22:32:18 +00:00
relays: Router.get().FromPubkeys([pubkey]).getUrls(),
2024-10-01 21:55:33 +00:00
})
})
</script>
2024-10-21 21:03:36 +00:00
<div class="card2 bg-alt col-2 shadow-xl">
<div class="flex justify-between">
<Profile {pubkey} />
2024-11-15 23:16:06 +00:00
<Link class="btn btn-primary hidden sm:flex" href={makeChatPath([pubkey])}>
<Icon icon="letter" />
Start a Chat
</Link>
</div>
2024-10-03 21:32:55 +00:00
<ProfileInfo {pubkey} />
2025-01-17 23:01:05 +00:00
{#if $events.length > 0}
2024-10-24 23:44:31 +00:00
<div class="bg-alt badge badge-neutral border-none">
2025-01-17 23:01:05 +00:00
Last active {formatTimestampRelative($events[0].created_at)}
2024-10-03 21:32:55 +00:00
</div>
{/if}
2024-11-15 23:16:06 +00:00
<Link class="btn btn-primary sm:hidden" href={makeChatPath([pubkey])}>
<Icon icon="letter" />
Start a Chat
</Link>
</div>