Skip to content

Commit

Permalink
Merge branch '2023.11' into 2024.11
Browse files Browse the repository at this point in the history
  • Loading branch information
gitlabci committed Feb 27, 2024
2 parents 087e6a7 + 5ac0ca1 commit 3b5a109
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions tine20/Felamimail/js/MailDetailsPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -513,13 +513,19 @@ Ext.extend(Tine.Felamimail.MailDetailsPanel, Ext.Panel, {
if (!attachment.promises) attachment.promises = [];
if (attachment?.isPreviewReady) return;
const promise = new Promise(async (resolve) => {
let validCache = null;
await Promise.all(attachment.promises).then((responses) => {
validCache = responses.find((r) => {return r.isPreviewReady});
});
const start = Date.now();
const responses = await Promise.all(attachment.promises);
const validCache = responses.find((r) => {return r.isPreviewReady});

if (validCache) {
attachment.isPreviewReady = true;
return resolve(validCache);
return resolve({
cache: validCache.cache,
createPreviewInstantly: createPreviewInstantly,
isPreviewReady: true,
skipSendRequest: true,
time: Date.now() - start,
});
}
const attachmentId = [sourceModel, record.id, attachment.partId].join(':');
await Tine.Felamimail.getAttachmentCache(attachmentId, createPreviewInstantly)
Expand All @@ -528,6 +534,7 @@ Ext.extend(Tine.Felamimail.MailDetailsPanel, Ext.Panel, {
cache: new Tine.Tinebase.Model.Tree_Node(cache.attachments[0]),
createPreviewInstantly: createPreviewInstantly,
isPreviewReady: cache.attachments[0].preview_count !== 0,
time: Date.now() - start,
});
})
.catch((e) => {
Expand Down

0 comments on commit 3b5a109

Please sign in to comment.