mirror of
https://github.com/coracle-social/coracle.git
synced 2024-09-15 17:53:36 +00:00
Fix nprofile scan when there are no relays
This commit is contained in:
parent
2781434b86
commit
17afc35d1c
@ -2,10 +2,11 @@
|
|||||||
import {objOf} from 'ramda'
|
import {objOf} from 'ramda'
|
||||||
import {onMount} from 'svelte'
|
import {onMount} from 'svelte'
|
||||||
import {nip19} from 'nostr-tools'
|
import {nip19} from 'nostr-tools'
|
||||||
|
import {warn} from 'src/util/logger'
|
||||||
import Content from 'src/partials/Content.svelte'
|
import Content from 'src/partials/Content.svelte'
|
||||||
import NoteDetail from 'src/views/notes/NoteDetail.svelte'
|
import NoteDetail from 'src/views/notes/NoteDetail.svelte'
|
||||||
import Person from 'src/views/person/PersonDetail.svelte'
|
import Person from 'src/views/person/PersonDetail.svelte'
|
||||||
import {getUserReadRelays} from 'src/agent/relays'
|
import {sampleRelays} from 'src/agent/relays'
|
||||||
|
|
||||||
export let entity
|
export let entity
|
||||||
|
|
||||||
@ -14,9 +15,9 @@
|
|||||||
onMount(() => {
|
onMount(() => {
|
||||||
try {
|
try {
|
||||||
({type, data} = nip19.decode(entity) as {type: string, data: any})
|
({type, data} = nip19.decode(entity) as {type: string, data: any})
|
||||||
relays = (data.relays || []).map(objOf('url')).concat(getUserReadRelays())
|
relays = sampleRelays((data.relays || []).map(objOf('url')))
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// pass
|
warn(e)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
@ -1,13 +1,15 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import type {ProfilePointer} from 'nostr-tools/nip19'
|
||||||
import QrScanner from 'qr-scanner'
|
import QrScanner from 'qr-scanner'
|
||||||
import {onDestroy} from 'svelte'
|
import {onDestroy} from 'svelte'
|
||||||
import {navigate} from 'svelte-routing'
|
import {navigate} from 'svelte-routing'
|
||||||
import {waitFor} from 'hurdak/lib/hurdak'
|
import {waitFor} from 'hurdak/lib/hurdak'
|
||||||
import {any, flip, startsWith} from 'ramda'
|
import {pluck, find} from 'ramda'
|
||||||
import {nip05, nip19} from 'nostr-tools'
|
import {nip05, nip19} from 'nostr-tools'
|
||||||
import Input from 'src/partials/Input.svelte'
|
import Input from 'src/partials/Input.svelte'
|
||||||
import Anchor from 'src/partials/Anchor.svelte'
|
import Anchor from 'src/partials/Anchor.svelte'
|
||||||
import Spinner from 'src/partials/Spinner.svelte'
|
import Spinner from 'src/partials/Spinner.svelte'
|
||||||
|
import {getUserReadRelays} from 'src/agent/relays'
|
||||||
import {toast} from "src/app/ui"
|
import {toast} from "src/app/ui"
|
||||||
|
|
||||||
let mode = 'input', video, ready, value, scanner
|
let mode = 'input', video, ready, value, scanner
|
||||||
@ -19,7 +21,7 @@
|
|||||||
const handleInput = async input => {
|
const handleInput = async input => {
|
||||||
input = input.replace('nostr:', '')
|
input = input.replace('nostr:', '')
|
||||||
|
|
||||||
if (any(flip(startsWith)(input), ["note1", "npub1", "nevent1", "nprofile1"])) {
|
if (find(s => input.startsWith(s), ["note1", "npub1", "nevent1", "nprofile1"])) {
|
||||||
navigate("/" + input)
|
navigate("/" + input)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -29,8 +31,12 @@
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
let profile = await nip05.queryProfile(input)
|
let profile = await nip05.queryProfile(input) as ProfilePointer
|
||||||
if (profile) {
|
if (profile) {
|
||||||
|
if (profile.relays.length === 0) {
|
||||||
|
profile.relays = pluck('url', getUserReadRelays())
|
||||||
|
}
|
||||||
|
|
||||||
navigate("/" + nip19.nprofileEncode(profile))
|
navigate("/" + nip19.nprofileEncode(profile))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user