diff --git a/dev/Common/UtilsUser.js b/dev/Common/UtilsUser.js index 692f82000..2a01115c8 100644 --- a/dev/Common/UtilsUser.js +++ b/dev/Common/UtilsUser.js @@ -301,10 +301,14 @@ populateMessageBody = (oMessage, popup) => { } else { let json = oData?.Result; if (json - && oMessage.hash === json.hash -// && oMessage.folder === json.folder -// && oMessage.uid == json.uid - && oMessage.revivePropertiesFromJson(json) + && (( + oMessage.hash && oMessage.hash === json.hash + ) || ( + !oMessage.hash + && oMessage.folder === json.folder + && oMessage.uid == json.uid) + ) + && oMessage.revivePropertiesFromJson(json) ) { /* if (bCached) { diff --git a/integrations/nextcloud/snappymail/js/snappymail.js b/integrations/nextcloud/snappymail/js/snappymail.js index fcbd88da3..289b54d66 100644 --- a/integrations/nextcloud/snappymail/js/snappymail.js +++ b/integrations/nextcloud/snappymail/js/snappymail.js @@ -13,6 +13,7 @@ document.onreadystatechange = () => { passThemesToIFrame(); let form = document.querySelector('form.snappymail'); form && SnappyMailFormHelper(form); + setupUnifiedSearchListener() } }; @@ -136,15 +137,22 @@ function SnappyMailFormHelper(oForm) return false; }); - } - catch(e) { + } catch (e) { console.error(e); } } -addEventListener('hashchange', (event) => { - const search = event.newURL.substring(event.newURL.lastIndexOf('/') + 1); - if (search && search.length < 25) { - document.getElementById('rliframe').contentWindow.rl.app.messageList.mainSearch(search); - } -}); +function setupUnifiedSearchListener() { + const iframe = document.getElementById('rliframe'); + if (!iframe || !iframe.contentWindow) return; + + addEventListener('hashchange', (event) => { + const hashIndex = event.newURL.indexOf('#/mailbox/'); + if (hashIndex !== -1) { + const hash = event.newURL.substring(hashIndex + 1); + if (/\/[\w-]+\/[\w-]+\/\w\d+\/.{0,24}/.test(hash)) { + iframe.contentWindow.location.hash = hash; + } + } + }); +}