From a83c3aacf82c44fd7ffabc9cacedfc0fcc5372c7 Mon Sep 17 00:00:00 2001 From: the-djmaze <> Date: Tue, 29 Oct 2024 01:29:52 +0100 Subject: [PATCH] Set identicon in cache when loading remote avatar fails --- plugins/avatars/avatars.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/plugins/avatars/avatars.js b/plugins/avatars/avatars.js index a325e9e3e..aad26d45f 100644 --- a/plugins/avatars/avatars.js +++ b/plugins/avatars/avatars.js @@ -79,7 +79,7 @@ (from.name?.split(/[^\p{L}]+/gu) || []).reduce((a, s) => a + (s[0] || ''), '') .slice(0,2) .toUpperCase(), - setIdenticon = (msg, fn) => { + setIdenticon = (msg, fn, cache) => { const from = email(msg); if (identicons.get(from)) { fn(identicons.get(from)); @@ -90,8 +90,9 @@ fromChars(msg.from[0]), window.getComputedStyle(getEl('rl-app'), null).getPropertyValue('font-family') )); - identicons.set(email(msg), uri); fn(uri); + identicons.set(email(msg), uri); + cache && avatars.set(getAvatarUid(msg), uri); }); } }, @@ -199,7 +200,7 @@ fn = url=>{element.src = url}; element.onerror = ()=>{ element.onerror = null; - setIdenticon(msg, fn); + setIdenticon(msg, fn, 1); }; if (url) { fn(url);