Support more bech32 entities

This commit is contained in:
Jonathan Staab 2023-01-13 04:12:49 -08:00
parent 6bec3d03e3
commit 98d3897e7c
3 changed files with 12 additions and 5 deletions

View File

@ -63,9 +63,7 @@ If you like Coracle and want to support its development, you can donate sats via
- [ ] Warn that everything will be cleared on logout - [ ] Warn that everything will be cleared on logout
- [ ] Clean up login page to prefer extension, make private key entry "advanced" - [ ] Clean up login page to prefer extension, make private key entry "advanced"
- [ ] Do I need to implement re-connecting now? - [ ] Do I need to implement re-connecting now?
- [ ] handle localstorage limits more robustly (prune accounts) https://stackoverflow.com/questions/2989284/what-is-the-max-size-of-localstorage-values
- [ ] Improve login UX for bootstrap delay. Nostr facts? - [ ] Improve login UX for bootstrap delay. Nostr facts?
- [ ] Use bech32 entities
- [ ] Revisit pagination. Use bigger timedelta + limit, set earliest seen timestamp when paginating? Handle no results on page. - [ ] Revisit pagination. Use bigger timedelta + limit, set earliest seen timestamp when paginating? Handle no results on page.
- [ ] We often get the root as the reply, figure out why that is, compared to astral/damus - [ ] We often get the root as the reply, figure out why that is, compared to astral/damus
- [ ] Alerts still aren't great. Maybe lazy load? We delete old events, so context will disappear and notes will become empty. - [ ] Alerts still aren't great. Maybe lazy load? We delete old events, so context will disappear and notes will become empty.

View File

@ -1,6 +1,8 @@
<script> <script>
import {nip19} from 'nostr-tools' import {nip19} from 'nostr-tools'
import {getRelays} from 'src/agent'
import NoteDetail from 'src/views/NoteDetail.svelte' import NoteDetail from 'src/views/NoteDetail.svelte'
import Person from 'src/routes/Person.svelte'
export let entity export let entity
@ -10,6 +12,12 @@
<div class="py-4 max-w-xl m-auto"> <div class="py-4 max-w-xl m-auto">
{#if type === "nevent"} {#if type === "nevent"}
<NoteDetail note={{id: data.id}} relays={data.relays} /> <NoteDetail note={{id: data.id}} relays={data.relays} />
{:else if type === "note"}
<NoteDetail note={{id: data}} relays={getRelays()} />
{:else if type === "nprofile"}
<Person npub={nip19.npubEncode(data.pubkey)} relays={data.relays} activeTab="notes" />
{:else if type === "npub"}
<Person npub={entity} activeTab="notes" />
{/if} {/if}
</div> </div>

View File

@ -20,6 +20,7 @@
export let npub export let npub
export let activeTab export let activeTab
export let relays = null
let subs = [] let subs = []
let pubkey = nip19.decode(npub).data let pubkey = nip19.decode(npub).data
@ -30,13 +31,13 @@
onMount(async () => { onMount(async () => {
// Refresh our person if needed // Refresh our person if needed
loaders.loadPeople(getRelays(pubkey), [pubkey]).then(() => { loaders.loadPeople(relays || getRelays(pubkey), [pubkey]).then(() => {
person = getPerson(pubkey, true) person = getPerson(pubkey, true)
}) })
// Get our followers count // Get our followers count
subs.push(await listen( subs.push(await listen(
getRelays(pubkey), relays || getRelays(pubkey),
[{kinds: [3], '#p': [pubkey]}], [{kinds: [3], '#p': [pubkey]}],
e => { e => {
followers.add(e.pubkey) followers.add(e.pubkey)
@ -57,7 +58,7 @@
const follow = async () => { const follow = async () => {
following = true following = true
const relay = first(getRelays(pubkey)) const relay = first(relays || getRelays(pubkey))
const tag = ["p", pubkey, relay, person.name || ""] const tag = ["p", pubkey, relay, person.name || ""]
const petnames = reject(t => t[1] === pubkey, $user.petnames).concat(tag) const petnames = reject(t => t[1] === pubkey, $user.petnames).concat(tag)