Skip to content

Commit

Permalink
Merge branch 'pu/ccheng/preview_improve' into '2023.11'
Browse files Browse the repository at this point in the history
tweak(Felamimail/js): log more attachment preview cache data

See merge request tine20/tine20!4978
  • Loading branch information
ccheng-dev committed Feb 27, 2024
2 parents c721d4c + 0971abd commit 5ac0ca1
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 @@ -510,13 +510,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 @@ -525,6 +531,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 5ac0ca1

Please sign in to comment.