From 118d954de095f233d0fd89f3f8186cba74c96159 Mon Sep 17 00:00:00 2001 From: Jonathan Staab Date: Wed, 5 Apr 2023 13:54:32 -0500 Subject: [PATCH] Spruce up scan/search/profile info/keys --- ROADMAP.md | 10 +- src/routes/Keys.svelte | 28 ++++-- src/routes/PersonDetail.svelte | 2 +- src/routes/Scan.svelte | 14 ++- src/routes/Search.svelte | 8 ++ src/views/Settings.svelte | 2 +- src/views/person/PersonProfileInfo.svelte | 111 +++++++--------------- 7 files changed, 80 insertions(+), 95 deletions(-) diff --git a/ROADMAP.md b/ROADMAP.md index 5f7fae4e..8510c7b8 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -4,13 +4,13 @@ - [ ] https://github.com/techfort/LokiJS - Use indexed adapter github.com/techfort/LokiJS/blob/master/tutorials/Persistence%20Adapters.md and partitioning adapter - Call close onbeforeunload to save pending changes + - Fix force relays on login: http://localhost:5173/messages/npub1l66wvfm7dxhd6wmvpukpjpyhvwtlxzu0qqajqxjfpr4rlfa8hl5qlkfr3q - [ ] Fix iOS/safari/firefox -- [ ] Revisit profile page and info, include similar access to hex keys etc on notes, keys page - - [ ] Add full profile details to key page - - [ ] Make profile edit more obvious - - [ ] Maybe consolidate settings pages into several sections, each with a modal +- [ ] Revisit profile page and info + - [ ] include similar access to hex keys etc on notes - [ ] Add zaps to likes tab - - [ ] Add like and zap details to note details + - [ ] Add hex key, like and zap info to note details +- [ ] Sort DMs, remember message status - [ ] Image classification - https://github.com/bhky/opennsfw2 - Requires updating my OS -_- diff --git a/src/routes/Keys.svelte b/src/routes/Keys.svelte index 689bd8db..981cf9e6 100644 --- a/src/routes/Keys.svelte +++ b/src/routes/Keys.svelte @@ -7,6 +7,7 @@ import Input from "src/partials/Input.svelte" import Anchor from "src/partials/Anchor.svelte" import Content from "src/partials/Content.svelte" + import Toggle from "src/partials/Toggle.svelte" import Heading from "src/partials/Heading.svelte" import keys from "src/agent/keys" import {toast} from "src/app/ui" @@ -15,9 +16,13 @@ const nip07 = "https://github.com/nostr-protocol/nips/blob/master/07.md" const keypairUrl = "https://www.cloudflare.com/learning/ssl/how-does-public-key-encryption-work/" - const copyKey = type => { - copyToClipboard(type === "private" ? nip19.nsecEncode($privkey) : nip19.npubEncode($pubkey)) + let asHex = false + $: pubkeyDisplay = asHex ? $pubkey : nip19.npubEncode($pubkey) + $: privkeyDisplay = asHex || !$privkey ? $privkey : nip19.nsecEncode($privkey) + + const copyKey = (type, value) => { + copyToClipboard(value) toast.show("info", `Your ${type} key has been copied to the clipboard.`) } @@ -32,7 +37,7 @@
-
+
Your Keys

Your account is identified across the network using a public/private

+
+
+ Show keys in hex format + +
+

+ Under the hood, Nostr uses a different encoding to represent keys. +

+
Public Key - +
- +
{#if person?.petnames} diff --git a/src/routes/Scan.svelte b/src/routes/Scan.svelte index 18031e71..517ebda5 100644 --- a/src/routes/Scan.svelte +++ b/src/routes/Scan.svelte @@ -4,6 +4,7 @@ import {navigate} from "svelte-routing" import {find} from "ramda" import {nip05, nip19} from "nostr-tools" + import Heading from "src/partials/Heading.svelte" import Input from "src/partials/Input.svelte" import Anchor from "src/partials/Anchor.svelte" import Spinner from "src/partials/Spinner.svelte" @@ -62,8 +63,15 @@ +
+ Find Something +

+ Enter any nostr identifier (npub, nevent, nprofile, note or user@domain.tld), or click on the + camera icon to scan with your device's camera instead. +

+
handleInput(value)}> - + handleInput(value)}> @@ -71,10 +79,6 @@ -
- Enter any nostr identifier (npub, nevent, nprofile, note or user@domain.tld), or click on the - camera icon to scan with your device's camera instead. -
{#if status === "loading"} Loading your camera... {/if} diff --git a/src/routes/Search.svelte b/src/routes/Search.svelte index a14a8cef..d3a0ecac 100644 --- a/src/routes/Search.svelte +++ b/src/routes/Search.svelte @@ -1,8 +1,16 @@ +
+ Profile Search +

+ Search for people on Nostr. For now, only profiles that have already been loaded will appear + in search results. +

+
diff --git a/src/views/Settings.svelte b/src/views/Settings.svelte index 1f4731c8..ba22a812 100644 --- a/src/views/Settings.svelte +++ b/src/views/Settings.svelte @@ -35,7 +35,7 @@
App Settings -

Tweak Coracle to work the way you want it to.

+

Make Coracle work the way you want it to.

diff --git a/src/views/person/PersonProfileInfo.svelte b/src/views/person/PersonProfileInfo.svelte index f2a1d503..02d76272 100644 --- a/src/views/person/PersonProfileInfo.svelte +++ b/src/views/person/PersonProfileInfo.svelte @@ -4,79 +4,45 @@ import Content from "src/partials/Content.svelte" import RelayCard from "src/views/relays/RelayCard.svelte" import {copyToClipboard} from "src/util/html" - import {warn} from "src/util/logger" import {onMount} from "svelte" import {fly} from "svelte/transition" export let person - // local items let nip05ProfileData = null - let nip05QueryEndpoint = null - let nProfile = null + let nprofile = null let npub = nip19.npubEncode(person.pubkey) - - // local state let loaded = false - onMount(() => { - if (person && person.verified_as) { - // get target URI - nip05QueryEndpoint = getNip05QueryEndpoint(person.verified_as) - - // calculate nProfile from NIP05 data, if available - nProfile = nip19.nprofileEncode({ + onMount(async () => { + if (person.verified_as) { + nprofile = nip19.nprofileEncode({ pubkey: person.pubkey, relays: person.relays, }) - // fetch data - nip05 - .queryProfile(person.verified_as) - .then(data => { - nip05ProfileData = data + try { + nip05ProfileData = await nip05.queryProfile(person.verified_as) + } catch (e) { + // Pass + } - // recalculate nprofile using NIP05 relay data, if specified. - // In theory, those *should* be the user's prefered relay set. - if (nip05ProfileData?.relays?.length) { - nProfile = nip19.nprofileEncode({ - pubkey: person.pubkey, - relays: nip05ProfileData.relays, - }) - } + // recalculate nprofile using NIP05 relay data, if specified. + // In theory, those *should* be the user's prefered relay set. + if (nip05ProfileData?.relays?.length) { + nprofile = nip19.nprofileEncode({ + pubkey: person.pubkey, + relays: nip05ProfileData.relays, }) - .catch(err => { - warn("NIP05 profile retrieval failed") - }) - .finally(() => { - loaded = true - }) - } else { - loaded = true + } } + + loaded = true }) - // Construct NIP05 URL from identifier. - function getNip05QueryEndpoint(identifier) { - if (!identifier) return null - - let name, domain - - if (identifier.match(/^.*@.*$/)) { - ;[name, domain] = identifier.split("@") - } else { - // In case of no name (domain-only), mimick the reasonable - // (but somewhat questionable) behaviour of nostr-tools/nip05, - // which defaults the name value - ;[name, domain] = ["_", identifier] - } - return `https://${domain}/.well-known/nostr.json?name=${name}` - } - - // helper: clipboard & toast - function copy(text) { + const copy = (label, text) => { copyToClipboard(text) - toast.show("info", `Copied.`) + toast.show("info", `${label} copied to clipboard!`) } @@ -86,7 +52,9 @@
Public Key (Hex)
-
@@ -94,17 +62,21 @@
Public Key (npub)
{#if npub} -
- {#if nProfile} -
-
nprofile
+ {#if nprofile} +
+
Profile Link
-
{/if} @@ -118,23 +90,11 @@ {#if person.verified_as}
-
-
NIP05 Validation Endpoint
-
- {#if nip05QueryEndpoint} -
-
{#if nip05ProfileData}
NIP05 Relay Configuration
@@ -142,14 +102,13 @@

These relays are advertised by the NIP05 identifier's validation endpoint.

-
{#each nip05ProfileData?.relays as url} {/each}
{:else} -

+

No relays are advertised by the NIP05 identifier's validation endpoint.