Skip to content
This repository has been archived by the owner on Nov 4, 2024. It is now read-only.

Commit

Permalink
Set identicon in cache when loading remote avatar fails
Browse files Browse the repository at this point in the history
  • Loading branch information
the-djmaze committed Oct 29, 2024
1 parent 8645b0a commit a83c3aa
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions plugins/avatars/avatars.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand All @@ -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);
});
}
},
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit a83c3aa

Please sign in to comment.