|
38 | 38 | queue = [],
|
39 | 39 | avatars = new Map,
|
40 | 40 | ncAvatars = new Map,
|
| 41 | + identicons = new Map, |
41 | 42 | templateId = 'MailMessageView',
|
42 | 43 | b64 = data => btoa(unescape(encodeURIComponent(data))),
|
43 | 44 | b64url = data => b64(data).replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, ''),
|
|
78 | 79 | (from.name?.split(/[^\p{L}]+/gu) || []).reduce((a, s) => a + (s[0] || ''), '')
|
79 | 80 | .slice(0,2)
|
80 | 81 | .toUpperCase(),
|
81 |
| - setIdenticon = (msg, fn) => hash(msg.from[0].email).then(hash => { |
82 |
| - const uri = 'data:image/svg+xml;base64,' + b64(window.identiconSvg( |
83 |
| - hash, |
84 |
| - fromChars(msg.from[0]), |
85 |
| - window.getComputedStyle(getEl('rl-app'), null).getPropertyValue('font-family') |
86 |
| - )); |
87 |
| -// avatars.set(getAvatarUid(msg), uri); |
88 |
| - fn(uri); |
89 |
| - }), |
| 82 | + setIdenticon = (msg, fn) => { |
| 83 | + const from = email(msg); |
| 84 | + if (identicons.get(from)) { |
| 85 | + fn(identicons.get(from)); |
| 86 | + } else { |
| 87 | + hash(from).then(hash => { |
| 88 | + const uri = 'data:image/svg+xml;base64,' + b64(window.identiconSvg( |
| 89 | + hash, |
| 90 | + fromChars(msg.from[0]), |
| 91 | + window.getComputedStyle(getEl('rl-app'), null).getPropertyValue('font-family') |
| 92 | + )); |
| 93 | + identicons.set(email(msg), uri); |
| 94 | + fn(uri); |
| 95 | + }); |
| 96 | + } |
| 97 | + }, |
90 | 98 |
|
91 | 99 | addQueue = (msg, fn) => {
|
92 | 100 | if (msg.from?.[0]) {
|
|
0 commit comments