Fix for mentions index.
I read the docs more thoroughly this time...
This commit is contained in:
parent
7ccb07ffc3
commit
8f14f77576
2 changed files with 17 additions and 8 deletions
|
@ -40,6 +40,15 @@ function event_get_pubkeys(ev) {
|
||||||
return keys;
|
return keys;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function event_get_tag_values(ev) {
|
||||||
|
const keys = [];
|
||||||
|
for (const tag of ev.tags) {
|
||||||
|
if (tag.length >= 2)
|
||||||
|
keys.push(tag[1]);
|
||||||
|
}
|
||||||
|
return keys;
|
||||||
|
}
|
||||||
|
|
||||||
function event_calculate_pow(ev) {
|
function event_calculate_pow(ev) {
|
||||||
const id_bits = leading_zero_bits(ev.id)
|
const id_bits = leading_zero_bits(ev.id)
|
||||||
for (const tag of ev.tags) {
|
for (const tag of ev.tags) {
|
||||||
|
|
16
js/ui/fmt.js
16
js/ui/fmt.js
|
@ -33,7 +33,7 @@ function format_content(model, ev, show_media) {
|
||||||
const content = (ev.kind == KIND_DM ? ev.decrypted || ev.content : ev.content)
|
const content = (ev.kind == KIND_DM ? ev.decrypted || ev.content : ev.content)
|
||||||
.trim();
|
.trim();
|
||||||
const body = fmt_mentions(model, fmt_body(content, show_media),
|
const body = fmt_mentions(model, fmt_body(content, show_media),
|
||||||
event_get_tagged_pubkeys(ev));
|
event_get_tag_values(ev));
|
||||||
let cw = get_content_warning(ev.tags)
|
let cw = get_content_warning(ev.tags)
|
||||||
if (cw !== null) {
|
if (cw !== null) {
|
||||||
let cwHTML = "Content Warning"
|
let cwHTML = "Content Warning"
|
||||||
|
@ -51,7 +51,7 @@ function format_content(model, ev, show_media) {
|
||||||
return body;
|
return body;
|
||||||
}
|
}
|
||||||
|
|
||||||
function fmt_mentions(model, str, pubkeys) {
|
function fmt_mentions(model, str, tags) {
|
||||||
var buf = "";
|
var buf = "";
|
||||||
for (var i = 0; i < str.length; i++) {
|
for (var i = 0; i < str.length; i++) {
|
||||||
let c = str.charAt(i);
|
let c = str.charAt(i);
|
||||||
|
@ -78,14 +78,14 @@ function fmt_mentions(model, str, pubkeys) {
|
||||||
}
|
}
|
||||||
if (x == "")
|
if (x == "")
|
||||||
continue;
|
continue;
|
||||||
// Specification says it's 0-based, but everyone is doing 1-base
|
// Specification says it's 0-based
|
||||||
let pubkey = pubkeys[parseInt(x)];
|
let ref = tags[parseInt(x)];
|
||||||
if (!pubkey) {
|
if (!ref) {
|
||||||
buf += "(Invalid User Mentioned)"
|
buf += `#[${x}]`
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
let profile = model_get_profile(model, pubkey);
|
let profile = model_get_profile(model, ref);
|
||||||
buf += `<span class="username clickable" data-pubkey="${pubkey}">
|
buf += `<span class="username clickable" data-pubkey="${ref}">
|
||||||
${fmt_name(profile)}</span>`;
|
${fmt_name(profile)}</span>`;
|
||||||
}
|
}
|
||||||
return buf;
|
return buf;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue