Tweak profiles/search

This commit is contained in:
Jon Staab
2025-06-05 12:25:55 -07:00
parent ac756bf266
commit e3fbd69e6e
11 changed files with 58 additions and 55 deletions
+33 -16
View File
@@ -2,15 +2,18 @@
import {onMount} from "svelte"
import {formatTimestampRelative} from "@welshman/lib"
import type {Filter} from "@welshman/util"
import {NOTE, GROUPS, MESSAGE, THREAD, COMMENT, getRelayTags, getListTags} from "@welshman/util"
import {deriveEvents} from "@welshman/store"
import {load} from "@welshman/net"
import {Router} from "@welshman/router"
import {repository, loadRelaySelections} from "@welshman/app"
import Icon from "@lib/components/Icon.svelte"
import Link from "@lib/components/Link.svelte"
import Button from "@lib/components/Button.svelte"
import Profile from "@app/components/Profile.svelte"
import ProfileInfo from "@app/components/ProfileInfo.svelte"
import {pubkeyLink} from "@app/state"
import ProfileDetail from "@app/components/ProfileDetail.svelte"
import {membershipsByPubkey} from "@app/state"
import {pushModal} from "@app/modal"
type Props = {
pubkey: string
@@ -18,17 +21,23 @@
}
const {pubkey, url}: Props = $props()
const filters: Filter[] = [{authors: [pubkey], limit: 1}]
const events = deriveEvents(repository, {filters})
const membership = $derived($membershipsByPubkey.get(pubkey))
const relays = $derived(getRelayTags(getListTags(membership)))
const openProfile = () => pushModal(ProfileDetail, {pubkey, url})
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 groups and at least one note, regardless of time frame
load({
filters: [{authors: [pubkey], limit: 1}],
filters: [
{authors: [pubkey], kinds: [GROUPS]},
{authors: [pubkey], limit: 1, kinds: [NOTE, MESSAGE, THREAD, COMMENT]},
],
relays: Router.get().FromPubkeys([pubkey]).getUrls(),
})
})
@@ -37,19 +46,27 @@
<div class="card2 bg-alt col-2 shadow-xl">
<div class="flex justify-between">
<Profile {pubkey} {url} />
<Link external href={pubkeyLink(pubkey)} class="btn btn-primary hidden sm:flex">
<Button onclick={openProfile} class="btn btn-primary hidden sm:flex">
<Icon icon="user-circle" />
See Complete Profile
</Link>
View Profile
</Button>
</div>
<ProfileInfo {pubkey} {url} />
{#if $events.length > 0}
<div class="bg-alt badge badge-neutral border-none">
Last active {formatTimestampRelative($events[0].created_at)}
</div>
{/if}
<Link external href={pubkeyLink(pubkey)} class="btn btn-primary sm:hidden">
<div class="flex flex-wrap gap-2">
{#if $events.length > 0}
<div class="badge badge-neutral">
Last active {formatTimestampRelative($events[0].created_at)}
</div>
{/if}
{#if relays.length > 0}
<div class="badge badge-neutral">
{relays.length}
{relays.length === 1 ? "space" : "spaces"}
</div>
{/if}
</div>
<Button onclick={openProfile} class="btn btn-primary sm:hidden">
<Icon icon="user-circle" />
See Complete Profile
</Link>
View Profile
</Button>
</div>
+3 -11
View File
@@ -1,11 +1,8 @@
<script lang="ts">
import * as nip19 from "nostr-tools/nip19"
import {removeNil} from "@welshman/lib"
import {displayPubkey, getPubkeyTagValues, getListTags} from "@welshman/util"
import {displayPubkey} from "@welshman/util"
import {
session,
userFollows,
deriveUserWotScore,
deriveHandleForPubkey,
displayHandle,
deriveProfile,
@@ -14,7 +11,7 @@
import Icon from "@lib/components/Icon.svelte"
import Button from "@lib/components/Button.svelte"
import Avatar from "@lib/components/Avatar.svelte"
import WotScore from "@lib/components/WotScore.svelte"
import WotScore from "@app/components/WotScore.svelte"
import ProfileDetail from "@app/components/ProfileDetail.svelte"
import {pushModal} from "@app/modal"
import {clip} from "@app/toast"
@@ -32,15 +29,10 @@
const profile = deriveProfile(pubkey, relays)
const profileDisplay = deriveProfileDisplay(pubkey, relays)
const handle = deriveHandleForPubkey(pubkey)
const score = deriveUserWotScore(pubkey)
const openProfile = () => pushModal(ProfileDetail, {pubkey, url})
const copyPubkey = () => clip(nip19.npubEncode(pubkey))
const following = $derived(
pubkey === $session!.pubkey || getPubkeyTagValues(getListTags($userFollows)).includes(pubkey),
)
</script>
<div class="flex max-w-full items-start gap-3">
@@ -52,7 +44,7 @@
<Button onclick={openProfile} class="text-bold overflow-hidden text-ellipsis">
{$profileDisplay}
</Button>
<WotScore score={$score} active={following} />
<WotScore {pubkey} />
</div>
{#if $handle}
<div class="overflow-hidden text-ellipsis text-sm opacity-75">
+3 -2
View File
@@ -1,6 +1,7 @@
<script lang="ts">
import {goto} from "$app/navigation"
import Icon from "@lib/components/Icon.svelte"
import Avatar from "@lib/components/Avatar.svelte"
import Link from "@lib/components/Link.svelte"
import Button from "@lib/components/Button.svelte"
import ModalFooter from "@lib/components/ModalFooter.svelte"
@@ -35,8 +36,8 @@
</Button>
<div class="flex gap-2">
<Link external href={pubkeyLink(pubkey)} class="btn btn-neutral">
<Icon icon="user-circle" />
See Complete Profile
<Avatar src="/coracle.png" />
Open in Coracle
</Link>
<Button onclick={openChat} class="btn btn-primary">
<Icon icon="letter" />
+1 -1
View File
@@ -14,5 +14,5 @@
</script>
{#if $profile}
<Content event={{content: $profile.about, tags: []}} hideMediaAtDepth={0} />
<Content event={{content: $profile.about || "", tags: []}} hideMediaAtDepth={0} />
{/if}
+50
View File
@@ -0,0 +1,50 @@
<style>
.wot-background {
fill: transparent;
stroke: var(--base-content);
opacity: 30%;
}
.wot-highlight {
fill: transparent;
stroke-width: 1.5;
stroke-dasharray: 100 100;
transform-origin: center;
}
</style>
<script lang="ts">
import {clamp} from "@welshman/lib"
import {pubkey, getFollows, deriveUserWotScore} from "@welshman/app"
interface Props {
pubkey: string
}
const {pubkey: target}: Props = $props()
const max = 100
const radius = 6
const center = radius + 1
const score = deriveUserWotScore(target)
const active = $derived(getFollows($pubkey!).includes(target))
const normalizedScore = $derived(clamp([0, max], $score) / max)
const dashOffset = $derived(100 - 44 * normalizedScore)
const style = $derived(`transform: rotate(${135 - normalizedScore * 180}deg)`)
const stroke = $derived(active ? "var(--primary)" : "var(--base-content)")
</script>
<div class="relative h-[14px] w-[14px]">
<svg height="14" width="14" class="absolute">
<circle class="wot-background" cx={center} cy={center} r={radius} />
<circle
cx={center}
cy={center}
r={radius}
class="wot-highlight"
stroke-dashoffset={dashOffset}
{style}
{stroke} />
</svg>
</div>