From 69a0116e44e3ab21c58e7ef42dd0cb777cdb340e Mon Sep 17 00:00:00 2001 From: yflory Date: Wed, 9 Mar 2022 15:42:09 +0100 Subject: [PATCH] Fix drive download issues with OnlyOffice documents --- www/common/onlyoffice/inner.js | 4 +++- www/common/onlyoffice/ooiframe.js | 10 +++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/www/common/onlyoffice/inner.js b/www/common/onlyoffice/inner.js index 547ef6c9d..d6024feb0 100644 --- a/www/common/onlyoffice/inner.js +++ b/www/common/onlyoffice/inner.js @@ -1804,6 +1804,7 @@ define([ } if (APP.isDownload) { + delete APP.isDownload; var bin = getContent(); if (!supportsXLSX()) { return void sframeChan.event('EV_OOIFRAME_DONE', bin, {raw: true}); @@ -2008,6 +2009,7 @@ Uncaught TypeError: Cannot read property 'calculatedType' of null var blobUrl = (typeof mediasData[data.src] === 'undefined') ? "" : mediasData[data.src].blobUrl; if (blobUrl) { + delete downloadImages[name]; debug("CryptPad Image already loaded " + blobUrl); return void callback(blobUrl); } @@ -2556,7 +2558,7 @@ Uncaught TypeError: Cannot read property 'calculatedType' of null type:'text/javascript', src: '/common/onlyoffice/'+version+'web-apps/apps/api/documents/api.js' }); - $('#cp-app-oo-editor').append(s); + $('#cp-app-oo-editor').empty().append(h('div#cp-app-oo-placeholder-a')).append(s); var hashes = content.hashes || {}; var idx = sortCpIndex(hashes); diff --git a/www/common/onlyoffice/ooiframe.js b/www/common/onlyoffice/ooiframe.js index 23c6424e3..c05c559fe 100644 --- a/www/common/onlyoffice/ooiframe.js +++ b/www/common/onlyoffice/ooiframe.js @@ -15,15 +15,17 @@ define([ var create = function (config) { // Loaded in load #2 var sframeChan; + var Util = config.modules.Utils.Util; + var _onReadyEvt = Util.mkEvent(true); var refresh = function (data, cb) { if (currentCb) { queue.push({data: data, cb: cb}); return; } if (!ready) { - ready = function () { + _onReadyEvt.reg(function () { refresh(data, cb); - }; + }); return; } currentCb = cb; @@ -152,10 +154,8 @@ define([ sframeChan.onReady(function () { if (ready === true) { return; } - if (typeof ready === "function") { - ready(); - } ready = true; + _onReadyEvt.fire(); }); }); });