From 86fb901f23eb6eb52ec0555d459d30916ae48c7a Mon Sep 17 00:00:00 2001 From: ccheng Date: Mon, 10 Feb 2025 06:41:34 +0100 Subject: [PATCH 1/2] fix(Felamimail/js): open email documents via existing cache in cross window --- tine20/Felamimail/js/MailDetailsPanel.js | 4 ++-- .../OnlyOfficeIntegrator/js/editDocumentAction.js | 14 +++++++++----- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/tine20/Felamimail/js/MailDetailsPanel.js b/tine20/Felamimail/js/MailDetailsPanel.js index fbbdb43a21c..d2af19af5fa 100644 --- a/tine20/Felamimail/js/MailDetailsPanel.js +++ b/tine20/Felamimail/js/MailDetailsPanel.js @@ -550,11 +550,11 @@ Ext.extend(Tine.Felamimail.MailDetailsPanel, Ext.Panel, { await Tine.Felamimail.getAttachmentCache(attachmentId, createPreviewInstantly) .then(async (cache) => { const cacheRecord = new Tine.Tinebase.Model.Tree_Node(cache.attachments[0]); - const isPreviewReady = cache.attachments[0].preview_count !== 0 && cache.attachments[0].path !== ''; + attachment.cache = cacheRecord; + const isPreviewReady = cache.attachments[0].preview_count !== 0 && cache.attachments[0].path !== ''; if (isPreviewReady) { attachment.isPreviewReady = true; - attachment.cache = cacheRecord; } return resolve({ cache: new Tine.Tinebase.Model.Tree_Node(cache.attachments[0]), diff --git a/tine20/OnlyOfficeIntegrator/js/editDocumentAction.js b/tine20/OnlyOfficeIntegrator/js/editDocumentAction.js index 76c0c3652ef..89bec12d7c4 100644 --- a/tine20/OnlyOfficeIntegrator/js/editDocumentAction.js +++ b/tine20/OnlyOfficeIntegrator/js/editDocumentAction.js @@ -24,12 +24,15 @@ Promise.all([ emailInterceptor: async function(config) { const mask = await config.setWaitText(app.i18n._('Preparing Attachment...')); - - if (config?.cachePromises) { + + if (config?.cache) { + config.recordData = config.cache?.data || config.cache; + } else if (config?.cachePromises) { // open document does not need to check preview status - await Promise.race(config.cachePromises) - .then((response) => { - config.recordData = response?.cache?.data; + await Promise.all(config?.cachePromises) + .then((responses) => { + const validPromise = responses.find((cachePromise) => !!cachePromise?.cache); + config.recordData = validPromise.cache.data; }) .catch((e) => { console.error(e); @@ -49,6 +52,7 @@ Promise.all([ const win = Tine.OnlyOfficeIntegrator.OnlyOfficeEditDialog.openWindow({ // always validate cachePromises to get the correct recordData cachePromises: record?.cachePromises, + cache: record?.data?.cache, recordData: recordData, id: record.id, contentPanelConstructorInterceptor: record?.cachePromises ? this.emailInterceptor : null From c0e74a1423c8027600defdf713668ab679b66890 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20Sch=C3=BCle?= Date: Mon, 10 Feb 2025 09:22:26 +0100 Subject: [PATCH 2/2] tweak(Tinebase/AreaLock): password can be null --- tine20/Tinebase/AreaLock.php | 4 ++-- tine20/Tinebase/Frontend/Json/AreaLock.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tine20/Tinebase/AreaLock.php b/tine20/Tinebase/AreaLock.php index ef85b936635..560d0110cd7 100644 --- a/tine20/Tinebase/AreaLock.php +++ b/tine20/Tinebase/AreaLock.php @@ -143,7 +143,7 @@ public function lock(string $areaLockName): Tinebase_Model_AreaLockState /** * @param string $areaLockName * @param string $userMfaId - * @param string $password + * @param null|string $password * @param Tinebase_Model_FullUser $identity * @return Tinebase_Model_AreaLockState * @throws Tinebase_Exception @@ -154,7 +154,7 @@ public function lock(string $areaLockName): Tinebase_Model_AreaLockState * @throws Tinebase_Exception_Record_Validation * @throws Zend_Session_Exception */ - public function unlock(string $areaLockName, string $userMfaId, string $password, Tinebase_Model_FullUser $identity): Tinebase_Model_AreaLockState + public function unlock(string $areaLockName, string $userMfaId, ?string $password, Tinebase_Model_FullUser $identity): Tinebase_Model_AreaLockState { /** @var Tinebase_Model_AreaLockConfig $areaConfig */ $areaConfig = $this->_getConfig()->records diff --git a/tine20/Tinebase/Frontend/Json/AreaLock.php b/tine20/Tinebase/Frontend/Json/AreaLock.php index 75b55f6e5bd..db94cc7168c 100644 --- a/tine20/Tinebase/Frontend/Json/AreaLock.php +++ b/tine20/Tinebase/Frontend/Json/AreaLock.php @@ -17,7 +17,7 @@ */ class Tinebase_Frontend_Json_AreaLock extends Tinebase_Frontend_Json_Abstract { - public function unlock(string $areaLockName, string $userMfaId, string $password = null): array + public function unlock(string $areaLockName, string $userMfaId, ?string $password = null): array { $result = Tinebase_AreaLock::getInstance()->unlock($areaLockName, $userMfaId, $password, Tinebase_Core::getUser());