From cc174060a330e8a8d755f6f549d4cea7ce631f3f Mon Sep 17 00:00:00 2001 From: OFF0 Date: Tue, 13 Dec 2022 20:48:44 +0100 Subject: [PATCH] profile: update profile images Textnotes often miss profile pictures of authors because they are rendered when received even without knowing the pic yet. Update profile pic of already rendered textnotes with the picture of the first kind 0 event that has a valid picture, should now render missing profile pics. --- src/main.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main.js b/src/main.js index 5d5baf9..e493330 100644 --- a/src/main.js +++ b/src/main.js @@ -414,9 +414,13 @@ function setMetadata(evt, relay, content) { timestamp: evt.created_at, ...content, }; + // use only the first profile pic (for now), different pics on each releay are not supported yet if (!user.picture) { user.picture = picture; - } // no support (yet) for other picture from same pubkey on different relays + // update profile images + feedContainer.querySelectorAll(`[data-pubkey="${user.pubkey.slice(0, 12)}"]`) + .forEach(img => img.setAttribute('src', picture)); + } } // if (tempContactList[relay]) { // const updates = tempContactList[relay].filter(update => update.pubkey === evt.pubkey); @@ -470,6 +474,7 @@ function getMetadata(evt, relay) { loading: 'lazy', src: userImg, title: `${userName} on ${host} ${userAbout}`, + data: {pubkey: user.pubkey.slice(0, 12)}, }) : elemCanvas(evt.pubkey); const isReply = evt.tags.some(hasEventTag); const replies = replyList.filter((reply) => reply.tags[0][1] === evt.id);