diff --git a/src/ConnectedWidget.svelte b/src/ConnectedWidget.svelte index 632cd26..378adf8 100644 --- a/src/ConnectedWidget.svelte +++ b/src/ConnectedWidget.svelte @@ -168,6 +168,10 @@ $: { connectedRelays = Object.values(connectivityStatus).filter(status => status === 'connected').length; totalRelays = Object.values(connectivityStatus).length; + + if ($chatAdapter?.pubkey && !profiles[$chatAdapter.pubkey]) { + $chatAdapter.reqProfile($chatAdapter.pubkey) + } } $: profiles = $chatData.profiles; @@ -181,6 +185,28 @@ scrollDown() } + + let ownName; + $: ownName = $chatAdapter?.pubkey ? pubkeyName($chatAdapter.pubkey) : ""; + + function pubkeyName(pubkey) { + let name; + + if (profiles[$chatAdapter.pubkey]) { + let self = profiles[$chatAdapter.pubkey]; + + // https://xkcd.com/927/ + name = self.display_name || + self.displayName || + self.name || + self.nip05; + + } + + if (!name) { name = `[${pubkey.slice(0, 6)}]`; } + + return name; + } @@ -194,7 +220,7 @@
{#if $chatAdapter?.pubkey} - {profiles[$chatAdapter.pubkey]?.display_name || $chatAdapter.pubkey} + {ownName} {/if}
diff --git a/src/KeyPrompt.svelte b/src/KeyPrompt.svelte index 719b699..cb924e5 100644 --- a/src/KeyPrompt.svelte +++ b/src/KeyPrompt.svelte @@ -77,14 +77,24 @@ }) await connect.init(); + let windowTitle, currentUrl, currentDomain; + + try { + windowTitle = window.document.title || 'Nostrichat'; + currentUrl = new URL(window.location.href); + currentDomain = currentUrl.hostname; + } catch (e) { + currentUrl = window.location.href; + currentDomain = currentUrl; + } + const connectURI = new ConnectURI({ target: getPublicKey(key), relay: 'wss://nostr.vulpem.com', metadata: { - name: 'PSBT.io', + name: windowTitle, description: '🔉🔉🔉', - url: 'https://psbt.io', - icons: ['https://example.com/icon.png'], + url: currentUrl, }, }); diff --git a/src/Widget.svelte b/src/Widget.svelte index 21ef999..0bfd9e2 100644 --- a/src/Widget.svelte +++ b/src/Widget.svelte @@ -94,13 +94,99 @@
- + Nostri.Chat + ">NostriChat - - + + + + + +
diff --git a/src/lib/adapters/index.js b/src/lib/adapters/index.js index 2aaf0b4..ce56e38 100644 --- a/src/lib/adapters/index.js +++ b/src/lib/adapters/index.js @@ -297,6 +297,10 @@ class NstrAdapter { // Profiles // // + reqProfile(pubkey) { + this.#addProfileRequest(pubkey); + } + #addProfileRequest(pubkey, event=null) { if (this.#profileRequestQueue.includes(pubkey)) { return; } if (this.#requestedProfiles.includes(pubkey)) { return; } diff --git a/src/routes/demo/+page.svelte b/src/routes/demo/+page.svelte index 63f7e65..e075580 100644 --- a/src/routes/demo/+page.svelte +++ b/src/routes/demo/+page.svelte @@ -15,7 +15,7 @@ src="/public/bundle.js" data-website-owner-pubkey="fa984bd7dbb282f07e16e7ae87b26a2a7b9b90b7246a44771f0cf5ae58018f52" data-chat-type="GLOBAL" - data-chat-tags="#nostrica" + data-chat-tags="nostrica" data-relays="wss://relay.f7z.io,wss://nos.lol,wss://relay.nostr.info,wss://nostr-pub.wellorder.net,wss://relay.current.fyi,wss://relay.nostr.band" >