web: fix updating profile view
This commit is contained in:
parent
7747ebb306
commit
d2cae71c9d
3 changed files with 17 additions and 8 deletions
|
@ -2,8 +2,8 @@ let DAMUS
|
|||
|
||||
const BOOTSTRAP_RELAYS = [
|
||||
"wss://relay.damus.io",
|
||||
//"wss://nostr-relay.wlvs.space",
|
||||
//"wss://nostr-pub.wellorder.net",
|
||||
"wss://nostr-relay.wlvs.space",
|
||||
"wss://nostr-pub.wellorder.net",
|
||||
]
|
||||
|
||||
// TODO autogenerate these constants with a bash script
|
||||
|
@ -138,6 +138,8 @@ function on_pool_open(relay) {
|
|||
kinds: STANDARD_KINDS,
|
||||
limit: 500,
|
||||
}]);
|
||||
|
||||
// TODO perhaps get our following list's history too
|
||||
}
|
||||
|
||||
function on_pool_notice(relay, notice) {
|
||||
|
|
|
@ -40,9 +40,7 @@ function view_timeline_apply_mode(model, mode, opts={}) {
|
|||
names[VM_THREAD] = "Thread";
|
||||
|
||||
// Do some visual updates
|
||||
find_node("#view header > label").innerText = mode == VM_USER ?
|
||||
fmt_profile_name(DAMUS.profiles[opts.pubkey], fmt_pubkey(opts.pubkey)) :
|
||||
names[mode];
|
||||
find_node("#view header > label").innerText = names[mode];
|
||||
find_node("#nav > div[data-active]").dataset.active = names[mode].toLowerCase();
|
||||
find_node("#view [role='profile-info']").classList.toggle("hide", mode != VM_USER);
|
||||
find_node("#newpost").classList.toggle("hide", mode != VM_FRIENDS);
|
||||
|
@ -213,6 +211,10 @@ function view_timeline_update_profiles(model, ev) {
|
|||
find_node(`.username[data-pubkey='${pk}']`, el).innerText = name;
|
||||
find_node(`img.pfp[data-pubkey='${pk}']`, el).src = pic;
|
||||
}
|
||||
// Update the profile view if it's active
|
||||
if (el.dataset.mode == VM_USER && el.dataset.pubkey == pk) {
|
||||
view_update_profile(model, pk);
|
||||
}
|
||||
}
|
||||
|
||||
function view_timeline_update_timestamps() {
|
||||
|
|
|
@ -282,13 +282,18 @@ function open_thread(thread_id) {
|
|||
|
||||
function open_profile(pubkey) {
|
||||
view_timeline_apply_mode(DAMUS, VM_USER, { pubkey });
|
||||
view_update_profile(DAMUS, pubkey);
|
||||
}
|
||||
|
||||
const profile = DAMUS.profiles[pubkey] || {};
|
||||
function view_update_profile(model, pubkey) {
|
||||
const profile = model.profiles[pubkey] || {};
|
||||
const el = find_node("[role='profile-info']");
|
||||
|
||||
|
||||
const name = fmt_profile_name(profile, fmt_pubkey(pubkey));
|
||||
find_node("#view header > label").innerText = name;
|
||||
find_node("[role='profile-image']", el).src = get_picture(pubkey, profile);
|
||||
find_nodes("[role='profile-name']", el).forEach(el => {
|
||||
el.innerText = fmt_profile_name(profile, fmt_pubkey(pubkey));
|
||||
el.innerText = name;
|
||||
});
|
||||
|
||||
const el_nip5 = find_node("[role='profile-nip5']", el)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue