Files
flotilla/src/app/components/Profile.svelte
T
2024-10-24 12:51:31 -07:00

44 lines
1.4 KiB
Svelte

<script lang="ts">
import {displayPubkey, getPubkeyTagValues, getListTags} from "@welshman/util"
import {
session,
userFollows,
deriveUserWotScore,
deriveProfile,
deriveHandleForPubkey,
displayHandle,
deriveProfileDisplay,
} from "@welshman/app"
import Link from "@lib/components/Link.svelte"
import Avatar from "@lib/components/Avatar.svelte"
import WotScore from "@lib/components/WotScore.svelte"
import {pubkeyLink} from "@app/state"
export let pubkey
const profile = deriveProfile(pubkey)
const profileDisplay = deriveProfileDisplay(pubkey)
const handle = deriveHandleForPubkey(pubkey)
const score = deriveUserWotScore(pubkey)
$: following =
pubkey === $session!.pubkey || getPubkeyTagValues(getListTags($userFollows)).includes(pubkey)
</script>
<div class="flex max-w-full gap-3">
<Link external href={pubkeyLink(pubkey)} class="py-1">
<Avatar src={$profile?.picture} size={10} />
</Link>
<div class="flex min-w-0 flex-col">
<div class="flex items-center gap-2">
<Link external href={pubkeyLink(pubkey)} class="text-bold overflow-hidden text-ellipsis">
{$profileDisplay}
</Link>
<WotScore score={$score} active={following} />
</div>
<div class="overflow-hidden text-ellipsis text-sm opacity-75">
{$handle ? displayHandle($handle) : displayPubkey(pubkey)}
</div>
</div>
</div>