diff --git a/src/lib/components/Login.svelte b/src/lib/components/Login.svelte index 84af5db..61b6ffa 100644 --- a/src/lib/components/Login.svelte +++ b/src/lib/components/Login.svelte @@ -3,11 +3,15 @@ import { activePubkey, loginWithExtension, logout, ndkInstance, ndkSignedIn, persistLogin } from '$lib/ndk'; import { Avatar, Button, Popover, Tooltip } from 'flowbite-svelte'; import { ArrowRightToBracketOutline } from 'flowbite-svelte-icons'; + import CopyToClipboard from "$components/util/CopyToClipboard.svelte"; let profile = $state(null); let pfp = $derived(profile?.image); let username = $derived(profile?.name); let tag = $derived(profile?.name); + let npub = $state(undefined); + + const externalProfileDestination = 'https://nostree.me/' let signInFailed = $state(false); @@ -19,6 +23,7 @@ .then(userProfile => { profile = userProfile; }); + npub = $ndkInstance.activeUser?.npub; } }); @@ -42,6 +47,11 @@ logout($ndkInstance.activeUser!); profile = null; } + + function shortenNpub(long: string|undefined) { + if (!long) return ''; + return long.slice(0, 8) + '…' + long.slice(-4); + } {#if $ndkSignedIn} @@ -61,6 +71,8 @@

{username}

@{tag}

+ + View profile
+ + + Copied! + +
diff --git a/src/lib/components/util/InlineProfile.svelte b/src/lib/components/util/InlineProfile.svelte new file mode 100644 index 0000000..9725194 --- /dev/null +++ b/src/lib/components/util/InlineProfile.svelte @@ -0,0 +1,49 @@ + + +{#if loading} + +{:else if pubkey} + + {username} +{:else} + Not found +{/if} \ No newline at end of file