mirror of
https://github.com/coracle-social/coracle.git
synced 2024-09-19 11:43:35 +00:00
Fix npub entities in notes
This commit is contained in:
parent
1719da5562
commit
db583e7ff2
@ -1,10 +1,13 @@
|
|||||||
# Current
|
# Current
|
||||||
|
|
||||||
- [ ] Fix notifications, separate into mentions/replies and other
|
- [ ] Fix notifications, separate into mentions/replies and other
|
||||||
- [ ] Render npubs properly http://localhost:5173/nevent1qqsqqr7r9w95lvj79zpsykup2d995jqhyxdntq98tu6tsvmjuh5ak9spz3mhxue69uhhyetvv9ujuerpd46hxtnfduyyc40u
|
|
||||||
- [ ] Links/topics/mentions open modals
|
- [ ] Links/topics/mentions open modals
|
||||||
- [ ] Render link previews inline rather than at bottom, check NostrReport for this
|
- [ ] Render link previews inline rather than at bottom, check NostrReport for this
|
||||||
- [ ] Wait for an auth challenge based on relay document to avoid missing first few REQs
|
- [ ] Wait for an auth challenge based on relay document to avoid missing first few REQs
|
||||||
|
- [ ] Extract libraries
|
||||||
|
- Cursor
|
||||||
|
- parseContent
|
||||||
|
- Tags
|
||||||
- [ ] Image classification
|
- [ ] Image classification
|
||||||
- https://github.com/bhky/opennsfw2
|
- https://github.com/bhky/opennsfw2
|
||||||
|
|
||||||
|
@ -122,18 +122,18 @@
|
|||||||
<br />
|
<br />
|
||||||
{/each}
|
{/each}
|
||||||
{:else if type === "topic"}
|
{:else if type === "topic"}
|
||||||
<Anchor stopPropagation on:click={() => openTopic(value)}>#{value}</Anchor>
|
<Anchor killEvent on:click={() => openTopic(value)}>#{value}</Anchor>
|
||||||
{:else if type === "link"}
|
{:else if type === "link"}
|
||||||
<Anchor external href={value}>
|
<Anchor external href={value}>
|
||||||
{value.replace(/https?:\/\/(www\.)?/, "")}
|
{value.replace(/https?:\/\/(www\.)?/, "")}
|
||||||
</Anchor>
|
</Anchor>
|
||||||
{:else if type.startsWith("nostr:")}
|
{:else if type.startsWith("nostr:")}
|
||||||
{#if value.pubkey}
|
{#if value.pubkey}
|
||||||
@<Anchor stopPropagation on:click={() => goToPerson(value.pubkey)}>
|
@<Anchor killEvent on:click={() => goToPerson(value.pubkey)}>
|
||||||
{displayPerson(getPersonWithFallback(value.pubkey))}
|
{displayPerson(getPersonWithFallback(value.pubkey))}
|
||||||
</Anchor>
|
</Anchor>
|
||||||
{:else}
|
{:else}
|
||||||
<Anchor stopPropagation href={"/" + value.entity}>
|
<Anchor killEvent href={"/" + value.entity}>
|
||||||
{value.entity.slice(0, 16) + "..."}
|
{value.entity.slice(0, 16) + "..."}
|
||||||
</Anchor>
|
</Anchor>
|
||||||
{/if}
|
{/if}
|
||||||
|
@ -2,9 +2,11 @@
|
|||||||
import cx from "classnames"
|
import cx from "classnames"
|
||||||
import {navigate} from "svelte-routing"
|
import {navigate} from "svelte-routing"
|
||||||
import {switcher} from "hurdak/lib/hurdak"
|
import {switcher} from "hurdak/lib/hurdak"
|
||||||
|
import {killEvent as _killEvent} from "src/util/html"
|
||||||
import {createEventDispatcher} from "svelte"
|
import {createEventDispatcher} from "svelte"
|
||||||
|
|
||||||
export let stopPropagation = false
|
export let stopPropagation = false
|
||||||
|
export let killEvent = false
|
||||||
export let external = false
|
export let external = false
|
||||||
export let loading = false
|
export let loading = false
|
||||||
export let type = "anchor"
|
export let type = "anchor"
|
||||||
@ -35,6 +37,10 @@
|
|||||||
)
|
)
|
||||||
|
|
||||||
const onClick = e => {
|
const onClick = e => {
|
||||||
|
if (killEvent) {
|
||||||
|
_killEvent(e)
|
||||||
|
}
|
||||||
|
|
||||||
if (stopPropagation) {
|
if (stopPropagation) {
|
||||||
e.stopPropagation()
|
e.stopPropagation()
|
||||||
}
|
}
|
||||||
|
@ -215,7 +215,13 @@ export const parseContent = ({content, tags = []}) => {
|
|||||||
try {
|
try {
|
||||||
const entity = bech32.replace("nostr:", "")
|
const entity = bech32.replace("nostr:", "")
|
||||||
const {type, data} = nip19.decode(entity) as {type: string; data: object}
|
const {type, data} = nip19.decode(entity) as {type: string; data: object}
|
||||||
const value = type === "note" ? {id: data} : data
|
|
||||||
|
let value = data
|
||||||
|
if (type === "note") {
|
||||||
|
value = {id: data}
|
||||||
|
} else if (type === "npub") {
|
||||||
|
value = {pubkey: data}
|
||||||
|
}
|
||||||
|
|
||||||
return [`nostr:${type}`, bech32, {...value, entity}]
|
return [`nostr:${type}`, bech32, {...value, entity}]
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
Loading…
Reference in New Issue
Block a user