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

Commit a83c3aa

Browse files
author
the-djmaze
committed
Set identicon in cache when loading remote avatar fails
1 parent 8645b0a commit a83c3aa

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

plugins/avatars/avatars.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@
7979
(from.name?.split(/[^\p{L}]+/gu) || []).reduce((a, s) => a + (s[0] || ''), '')
8080
.slice(0,2)
8181
.toUpperCase(),
82-
setIdenticon = (msg, fn) => {
82+
setIdenticon = (msg, fn, cache) => {
8383
const from = email(msg);
8484
if (identicons.get(from)) {
8585
fn(identicons.get(from));
@@ -90,8 +90,9 @@
9090
fromChars(msg.from[0]),
9191
window.getComputedStyle(getEl('rl-app'), null).getPropertyValue('font-family')
9292
));
93-
identicons.set(email(msg), uri);
9493
fn(uri);
94+
identicons.set(email(msg), uri);
95+
cache && avatars.set(getAvatarUid(msg), uri);
9596
});
9697
}
9798
},
@@ -199,7 +200,7 @@
199200
fn = url=>{element.src = url};
200201
element.onerror = ()=>{
201202
element.onerror = null;
202-
setIdenticon(msg, fn);
203+
setIdenticon(msg, fn, 1);
203204
};
204205
if (url) {
205206
fn(url);

0 commit comments

Comments
 (0)