From 153d69f33dc79fb2929cac4e67db7065be32069d Mon Sep 17 00:00:00 2001 From: Thomas Mathews Date: Sat, 24 Dec 2022 05:49:40 -0800 Subject: [PATCH] Fix profile picture initial state & no image. --- js/main.js | 1 + js/ui/render.js | 2 +- js/ui/util.js | 7 ++----- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/js/main.js b/js/main.js index 27fc681..fe42cd4 100644 --- a/js/main.js +++ b/js/main.js @@ -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); }); diff --git a/js/ui/render.js b/js/ui/render.js index 5a179d2..3ac13b6 100644 --- a/js/ui/render.js +++ b/js/ui/render.js @@ -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)}"/>` } diff --git a/js/ui/util.js b/js/ui/util.js index 4f519b3..7657242 100644 --- a/js/ui/util.js +++ b/js/ui/util.js @@ -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; }