From 7fb3d6f120e1c049433f0fd84352413911d40659 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nu=C5=A1a=20Puk=C5=A1i=C4=8D?= Date: Sat, 8 Mar 2025 09:27:41 +0100 Subject: [PATCH] open #133 active user data --- src/lib/components/Login.svelte | 12 +++++ .../components/util/CopyToClipboard.svelte | 29 +++++++++++ src/lib/components/util/InlineProfile.svelte | 49 +++++++++++++++++++ 3 files changed, 90 insertions(+) create mode 100644 src/lib/components/util/CopyToClipboard.svelte create mode 100644 src/lib/components/util/InlineProfile.svelte 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