Better mention support, fixed open thread.
This commit is contained in:
parent
21ce55f1cd
commit
3970bb5acd
3 changed files with 16 additions and 9 deletions
|
@ -32,6 +32,9 @@ th, td {
|
|||
font-size: var(--fsNormal);
|
||||
}
|
||||
|
||||
.bold {
|
||||
font-weight: bold;
|
||||
}
|
||||
.row {
|
||||
margin: 15px 0;
|
||||
}
|
||||
|
|
14
js/ui/fmt.js
14
js/ui/fmt.js
|
@ -32,8 +32,7 @@ function format_content(model, ev, show_media) {
|
|||
}
|
||||
const content = (ev.kind == KIND_DM ? ev.decrypted || ev.content : ev.content)
|
||||
.trim();
|
||||
const body = fmt_mentions(model, fmt_body(content, show_media),
|
||||
event_get_tag_values(ev));
|
||||
const body = fmt_mentions(model, fmt_body(content, show_media), ev.tags);
|
||||
let cw = get_content_warning(ev.tags)
|
||||
if (cw !== null) {
|
||||
let cwHTML = "Content Warning"
|
||||
|
@ -78,16 +77,21 @@ function fmt_mentions(model, str, tags) {
|
|||
}
|
||||
if (x == "")
|
||||
continue;
|
||||
// Specification says it's 0-based
|
||||
let ref = tags[parseInt(x)];
|
||||
if (!ref) {
|
||||
let tag = tags[parseInt(x)];
|
||||
if (!tag) {
|
||||
buf += `#[${x}]`
|
||||
continue;
|
||||
}
|
||||
let ref = tag[1];
|
||||
if (tag[0] == 'e') {
|
||||
buf += `<span class="clickable bold" action="open-thread"
|
||||
data-thread-id="${ref}">note:${fmt_pubkey(ref)}</span>`;
|
||||
} else if (tag[0] == 'p') {
|
||||
let profile = model_get_profile(model, ref);
|
||||
buf += `<span class="username clickable" data-pubkey="${ref}">
|
||||
${fmt_name(profile)}</span>`;
|
||||
}
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
|
||||
|
|
|
@ -599,7 +599,7 @@ function onclick_any(ev) {
|
|||
show_new();
|
||||
break;
|
||||
case "open-thread":
|
||||
open_trhead(el.dataset.threadId);
|
||||
open_thread(el.dataset.threadId);
|
||||
break;
|
||||
case "reply":
|
||||
send_reply(el.dataset.emoji, el.dataset.to);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue