From 3175da546b5c72b88a0f74b8b8776d0f04ffccf7 Mon Sep 17 00:00:00 2001 From: Bob Date: Wed, 21 Aug 2024 16:57:34 +0800 Subject: [PATCH] problem: can't see info about contributors resolve https://github.com/nostrocket/hypergolic/issues/118 --- src/components/MeritsAndSatflow.svelte | 30 +++-- src/components/ProfileCard.svelte | 152 +++++++++++++++++++++++++ 2 files changed, 174 insertions(+), 8 deletions(-) create mode 100644 src/components/ProfileCard.svelte diff --git a/src/components/MeritsAndSatflow.svelte b/src/components/MeritsAndSatflow.svelte index 3c7ed14..19b4299 100644 --- a/src/components/MeritsAndSatflow.svelte +++ b/src/components/MeritsAndSatflow.svelte @@ -10,9 +10,12 @@ import { toast } from 'svelte-sonner'; import { onMount } from 'svelte'; import PurchaseToast from './PurchaseToast.svelte'; + import ProductCard from './ProductCard.svelte'; import { devmode } from '@/stores/session'; import Button from '@/components/ui/button/button.svelte'; + import * as HoverCard from '$lib/components/ui/hover-card'; import { sleep } from '@/helpers'; + import ProfileCard from './ProfileCard.svelte'; export let rocket: Rocket; export let unratifiedZaps: Map; @@ -160,14 +163,25 @@ on:mouseleave={handleRowLeave} > -
- -
+ + +
+ +
+
+ + + +
+ import { ndk } from '@/ndk'; + import { Avatar, Name } from '@nostr-dev-kit/ndk-svelte-components'; + import { fade } from 'svelte/transition'; + import { nip19 } from 'nostr-tools'; + + export let pubkey: string; + + const npub = nip19.npubEncode(pubkey); + const nprofile = nip19.nprofileEncode({ + pubkey: pubkey, + relays: [ + 'wss://relay.nostr.band', + 'wss://nos.lol', + 'wss://relay.nostrocket.org', + 'wss://relay.damus.io' + ] + }); + + async function getUserProfile(pubkey: string) { + try { + const user = $ndk.getUser({ pubkey }); + await user.fetchProfile(); + return user.profile; + } catch (error) { + console.error('Error retrieving profile:', error); + } + } + + function getNostrClientLinks(npub: string, nprofile: string) { + return [ + { name: 'Nosta', url: `https://nosta.me/${nprofile}` }, + { name: 'Primal', url: `https://primal.net/p/${npub}` }, + { name: 'Nostrudel', url: `https://nostrudel.ninja/#/u/${nprofile}` }, + { name: 'Coracle', url: `https://coracle.social/${nprofile}` } + ]; + } + + let isCopied = false; + + function copyPubkey() { + navigator.clipboard.writeText(npub).then( + () => { + isCopied = true; + setTimeout(() => { + isCopied = false; + }, 2000); + }, + (err) => { + console.error('Copy failed: ', err); + } + ); + } + + function ensureHttps(url: string): string { + if (url.startsWith('http://') || url.startsWith('https://')) { + return url; + } + return `https://${url}`; + } + + +
+
+ +
+ + +
+
+ + {#await getUserProfile(pubkey)} +
+
+ {:then profile} + {#if profile} +
+ {#if profile.about} +

{profile.about}

+ {/if} + {#if profile.website} +

+ + {profile.website} + +

+ {/if} + {#if profile.nip05} +

+ NIP-05: {profile.nip05} +

+ {/if} +
+ {:else} +

No profile information available.

+ {/if} + +
+

Open in Nostr client:

+
+ {#each getNostrClientLinks(npub, nprofile) as link} + + {link.name} + + {/each} +
+
+ {:catch error} +

Failed to load profile: {error.message}

+ {/await} +