diff --git a/public/index.html b/public/index.html index a17838d91..554bed678 100644 --- a/public/index.html +++ b/public/index.html @@ -1,20 +1,23 @@ - - - - - - - - - snort.social - Nostr interface - - - -
- - + + + + + + + + + + + + snort.social - Nostr interface + + + + +
+ + + \ No newline at end of file diff --git a/src/element/Note.js b/src/element/Note.js index 6388d18b5..f191f75ac 100644 --- a/src/element/Note.js +++ b/src/element/Note.js @@ -54,8 +54,6 @@ export default function Note(props) { function transformBody() { let body = ev.Content; - let pTags = ev.Tags.filter(a => a.Key === "p"); - let urlBody = body.split(UrlRegex); return urlBody.map(a => { @@ -84,15 +82,23 @@ export default function Note(props) { } } else { let mentions = a.split(MentionRegex).map((match) => { - if (match.startsWith("#")) { - let idx = parseInt(match.match(/\[(\d+)\]/)[1]); - let pref = pTags[idx]; - if (pref) { - let pUser = users[pref.PubKey]?.name ?? pref.PubKey.substring(0, 8); - return #{pUser}; - } else { - return
BROKEN REF: {match[0]}
; - } + let matchTag = match.match(/#\[(\d+)\]/); + if (matchTag && matchTag.length === 2) { + let idx = parseInt(matchTag[1]); + let ref = ev.Tags.find(a => a.Index === idx); + if (ref) { + switch(ref.Key) { + case "p": { + let pUser = users[ref.PubKey]?.name ?? ref.PubKey.substring(0, 8); + return @{pUser}; + } + case "e": { + let eText = ref.Event.substring(0, 8); + return #{eText}; + } + } + } + return {matchTag[0]}?; } else { return match; } @@ -128,6 +134,9 @@ export default function Note(props) { 👍 {(reactions?.length ?? 0)} + console.debug(ev)}> + i + ) diff --git a/src/index.css b/src/index.css index a2c433345..f5b2abf8a 100644 --- a/src/index.css +++ b/src/index.css @@ -72,7 +72,7 @@ span.pill { padding: 0 10px; border-radius: 10px; user-select: none; - margin: 2px 10px; + margin: 2px 5px; } span.pill:hover {