diff --git a/plugins/avatars/avatars.js b/plugins/avatars/avatars.js
index 4b9d2bdf0..8aef7fa69 100644
--- a/plugins/avatars/avatars.js
+++ b/plugins/avatars/avatars.js
@@ -76,6 +76,8 @@
if (rl.pluginSettingsGet('avatars', 'delay')) {
queue.push([msg, fn]);
runQueue();
+ } else if (msg.avatar) {
+ fn(getAvatarUrl(msg));
}
},
runQueue = (() => {
@@ -88,6 +90,8 @@
item[1](url);
item = queue.shift();
continue;
+ } else if (item[0].avatar) {
+ item[1](getAvatarUrl(item[0]));
} else if (!avatars.has(uid)) {
let from = item[0].from[0];
rl.pluginRemoteRequest((iError, data) => {
@@ -104,7 +108,6 @@
bimiSelector: getBimiSelector(item[0]),
email: from.email
});
- break;
}
}
runQueue();
@@ -112,10 +115,22 @@
}
}).debounce(1000);
- /**
- * Loads images from Nextcloud contacts
- */
- addEventListener('DOMContentLoaded', () => {
+// addEventListener('DOMContentLoaded', () => {
+ /**
+ * Modify templates
+ */
+ getEl('MailMessageList').content.querySelectorAll('.messageCheckbox')
+ .forEach(el => el.append(Element.fromHTML(`
`)));
+ const messageItemHeader = getEl(templateId).content.querySelector('.messageItemHeader');
+ if (messageItemHeader) {
+ messageItemHeader.prepend(Element.fromHTML(
+ `
`
+ ));
+ }
+
+ /**
+ * Loads images from Nextcloud contacts
+ */
// rl.pluginSettingsGet('avatars', 'nextcloud');
if (parent.OC?.requestToken) {
const OC = parent.OC,
@@ -160,24 +175,21 @@
}
});
}
- });
+// });
+ /**
+ * Used by MailMessageList
+ */
ko.bindingHandlers.fromPic = {
init: (element, self, dummy, msg) => {
try {
if (msg?.from?.[0]) {
let url = getAvatar(msg),
- from = msg.from[0],
fn = url=>{element.src = url};
if (url) {
fn(url);
- } else if (msg.avatar) {
- if (msg.avatar?.startsWith('data:')) {
- fn(msg.avatar);
- } else {
- element.onerror = () => setIdenticon(from, fn);
- fn(getAvatarUrl(msg));
- }
+ } else if (msg.avatar?.startsWith('data:')) {
+ fn(msg.avatar);
} else {
addQueue(msg, fn);
}
@@ -190,17 +202,6 @@
addEventListener('rl-view-model.create', e => {
if (templateId === e.detail.viewModelTemplateID) {
-
- const
- template = getEl(templateId),
- messageItemHeader = template.content.querySelector('.messageItemHeader');
-
- if (messageItemHeader) {
- messageItemHeader.prepend(Element.fromHTML(
- `
`
- ));
- }
-
let view = e.detail;
view.viewUserPic = ko.observable('');
view.viewUserPicVisible = ko.observable(false);
@@ -226,11 +227,6 @@
}
});
}
-
- if ('MailMessageList' === e.detail.viewModelTemplateID) {
- getEl('MailMessageList').content.querySelectorAll('.messageCheckbox')
- .forEach(el => el.append(Element.fromHTML(`
`)));
- }
});
})(window.rl);
diff --git a/plugins/avatars/index.php b/plugins/avatars/index.php
index e47f2df85..a1a5b921f 100644
--- a/plugins/avatars/index.php
+++ b/plugins/avatars/index.php
@@ -10,8 +10,8 @@ class AvatarsPlugin extends \RainLoop\Plugins\AbstractPlugin
NAME = 'Avatars',
AUTHOR = 'SnappyMail',
URL = 'https://snappymail.eu/',
- VERSION = '1.18',
- RELEASE = '2024-06-24',
+ VERSION = '1.19',
+ RELEASE = '2024-07-08',
REQUIRED = '2.33.0',
CATEGORY = 'Contacts',
LICENSE = 'MIT',
@@ -28,7 +28,12 @@ class AvatarsPlugin extends \RainLoop\Plugins\AbstractPlugin
$this->addJs("{$identicon}.js");
}
// https://github.com/the-djmaze/snappymail/issues/714
- if ($this->Config()->Get('plugin', 'service', true) || !$this->Config()->Get('plugin', 'delay', true)) {
+ if ($this->Config()->Get('plugin', 'service', true)
+// || !$this->Config()->Get('plugin', 'delay', true)
+ || $this->Config()->Get('plugin', 'gravatar', false)
+ || $this->Config()->Get('plugin', 'bimi', false)
+ || $this->Config()->Get('plugin', 'favicon', false)
+ ) {
$this->addHook('json.after-message', 'JsonMessage');
$this->addHook('json.after-messagelist', 'JsonMessageList');
}
@@ -69,8 +74,8 @@ class AvatarsPlugin extends \RainLoop\Plugins\AbstractPlugin
$mFrom = $mFrom->jsonSerialize();
}
if (\is_array($mFrom)) {
- if (!$this->Config()->Get('plugin', 'delay', true)
- && ($this->Config()->Get('plugin', 'gravatar', false)
+ if (/*!$this->Config()->Get('plugin', 'delay', true)
+ && */($this->Config()->Get('plugin', 'gravatar', false)
|| ($this->Config()->Get('plugin', 'bimi', false) && 'pass' == $mFrom['dkimStatus'])
|| ($this->Config()->Get('plugin', 'favicon', false) && 'pass' == $mFrom['dkimStatus'])
)