Fix profile picture initial state & no image.

This commit is contained in:
Thomas Mathews 2022-12-24 05:49:40 -08:00
parent 2288afbba3
commit 153d69f33d
3 changed files with 4 additions and 6 deletions

View file

@ -70,6 +70,7 @@ async function webapp_init() {
// WARNING Order Matters!
init_message_textareas();
view_show_spinner(true);
redraw_my_pfp(model);
document.addEventListener('visibilitychange', () => {
update_title(model);
});

View file

@ -288,7 +288,7 @@ function render_pfp(pk, profile, opts={}) {
$${str}
data-pubkey="${pk}"
title="${name}"
onerror="this.onerror=null;this.src='./icon/no-user.svg';"
onerror="this.onerror=null;this.src='${IMG_NO_USER}';"
src="${get_picture(pk, profile)}"/>`
}

View file

@ -204,13 +204,10 @@ function reply_to(evid) {
replybox.focus()
}
function redraw_my_pfp(model, force = false) {
function redraw_my_pfp(model) {
const p = model.profiles[model.pubkey]
if (!p) return;
const html = render_pfp(model.pubkey, p);
const html = render_pfp(model.pubkey, p || {});
const el = document.querySelector(".my-userpic");
if (!force && el.dataset.loaded) return;
el.dataset.loaded = true;
el.innerHTML = html;
}