flotilla/src/routes/people/[npub]/+page.svelte

77 lines
2 KiB
Svelte
Raw Normal View History

<script lang="ts">
import {onMount} from "svelte"
import {page} from "$app/stores"
import {goto} from "$app/navigation"
import type {MakeNonOptional} from "@welshman/lib"
import type {Filter} from "@welshman/util"
import {ROOMS, NOTE, FOLLOWS} from "@welshman/util"
2026-07-28 16:16:26 +00:00
import {outbox} from "@welshman/util"
import {PinLists} from "@welshman/app"
import {decodePubkey} from "@lib/util"
import Page from "@lib/components/Page.svelte"
import PageContent from "@lib/components/PageContent.svelte"
import ProfilePage from "@app/components/ProfilePage.svelte"
import {pushToast} from "@app/toast"
2026-07-28 16:16:26 +00:00
import {
app,
followLists,
messagingRelayLists,
network,
profiles,
relayLists,
roomLists,
router,
user,
} from "@app/core"
const {npub} = $page.params as MakeNonOptional<typeof $page.params>
2026-06-29 23:28:11 +00:00
const pubkey = decodePubkey(npub)
onMount(async () => {
2026-06-29 23:28:11 +00:00
if (!pubkey) {
2026-09-15 18:07:47 +00:00
return goto("/", {replaceState: true})
}
try {
2026-07-28 16:16:26 +00:00
await $profiles.load(pubkey)
await $relayLists.load(pubkey)
2026-07-28 16:16:26 +00:00
const viewer = user.get().pubkey
await Promise.all([
2026-07-28 16:16:26 +00:00
$followLists.load(pubkey),
$app.use(PinLists).load(pubkey),
$roomLists.load(pubkey),
$messagingRelayLists.load(pubkey),
viewer && viewer !== pubkey ? $followLists.load(viewer) : undefined,
])
const filters: Filter[] = [
{authors: [pubkey], kinds: [ROOMS]},
{authors: [pubkey], kinds: [NOTE], limit: 1},
]
2026-07-28 16:16:26 +00:00
if (viewer === pubkey) {
filters.push({kinds: [FOLLOWS], "#p": [pubkey], limit: 500})
}
2026-07-28 16:16:26 +00:00
$network.load({
relays: await $router.resolver.relays([outbox(pubkey)]),
filters,
})
} catch (e) {
console.error(e)
pushToast({theme: "error", message: "Some of this profile could not be loaded."})
}
})
</script>
<Page>
<PageContent class="p-0 md:p-4">
2026-06-29 23:28:11 +00:00
{#if pubkey}
<ProfilePage {pubkey} />
{/if}
</PageContent>
</Page>