mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-08 22:18:28 +03:00
Reduce amount of server requests to fetch remote avatars
This commit is contained in:
parent
c56cc7be73
commit
4d0ee8736b
1 changed files with 9 additions and 3 deletions
|
|
@ -37,17 +37,20 @@
|
|||
runQueue = (() => {
|
||||
let item = queue.shift();
|
||||
while (item) {
|
||||
let url = getAvatar(item[0]);
|
||||
let url = getAvatar(item[0]),
|
||||
uid = getAvatarUid(item[0]);
|
||||
if (url) {
|
||||
item[1](url);
|
||||
item = queue.shift();
|
||||
} else {
|
||||
} else if (!avatars.has(uid)) {
|
||||
let from = item[0].from[0];
|
||||
rl.pluginRemoteRequest((iError, data) => {
|
||||
if (!iError && data?.Result.type) {
|
||||
url = `data:${data.Result.type};base64,${data.Result.data}`;
|
||||
avatars.set(getAvatarUid(item[0]), url);
|
||||
avatars.set(uid, url);
|
||||
item[1](url);
|
||||
} else {
|
||||
avatars.set(uid, '');
|
||||
}
|
||||
runQueue();
|
||||
}, 'Avatar', {
|
||||
|
|
@ -55,6 +58,9 @@
|
|||
email: from.email
|
||||
});
|
||||
break;
|
||||
} else {
|
||||
runQueue();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}).debounce(1000);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue