From d13885bb0883bc0c666cb246982bd94f4b46e794 Mon Sep 17 00:00:00 2001 From: yflory Date: Wed, 28 Apr 2021 18:21:11 +0200 Subject: [PATCH 1/2] Add XXX --- www/common/sframe-common-file.js | 1 + 1 file changed, 1 insertion(+) diff --git a/www/common/sframe-common-file.js b/www/common/sframe-common-file.js index 2a6f4fea3..4274a5538 100644 --- a/www/common/sframe-common-file.js +++ b/www/common/sframe-common-file.js @@ -129,6 +129,7 @@ define([ var l = privateData.plan ? ApiConfig.premiumUploadSize : false; l = l || ApiConfig.maxUploadSize || "?"; var maxSizeStr = Util.bytesToMegabytes(l); + // XXX blob.byteLength is wrong: we should use the lenght of the encrypted content (see whiteboard) if (blob && blob.byteLength && typeof(l) === "number" && blob.byteLength > l) { $pv.text(Messages.error); queue.inProgress = false; From db65659afb0b8ef03bb6467ef76eda8c785fd840 Mon Sep 17 00:00:00 2001 From: yflory Date: Wed, 28 Apr 2021 18:21:28 +0200 Subject: [PATCH 2/2] Fix small OO bugs --- www/common/cryptpad-common.js | 5 +++++ www/common/onlyoffice/inner.js | 13 ++++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/www/common/cryptpad-common.js b/www/common/cryptpad-common.js index 7d6fee8b7..63ca53f1c 100644 --- a/www/common/cryptpad-common.js +++ b/www/common/cryptpad-common.js @@ -2374,9 +2374,14 @@ define([ }; postMsg('INIT'); + /* window.addEventListener('beforeunload', function () { postMsg('CLOSE'); }); + */ + window.addEventListener('unload', function () { + postMsg('CLOSE'); + }); } else if (false && !noWorker && !noSharedWorker && 'serviceWorker' in navigator) { var initializing = true; var stopWaiting = waitFor2(); // Call this function when we're ready diff --git a/www/common/onlyoffice/inner.js b/www/common/onlyoffice/inner.js index 120b07e46..b88d98617 100644 --- a/www/common/onlyoffice/inner.js +++ b/www/common/onlyoffice/inner.js @@ -2202,20 +2202,22 @@ define([ } }; + var wasEditing = false; var setStrictEditing = function () { if (APP.isFast) { return; } var editor = getEditor(); - var isModified = editor.asc_isDocumentModified || editor.isDocumentModified; - var editing = isModified(); + var editing = editor.asc_isDocumentModified ? editor.asc_isDocumentModified() : editor.isDocumentModified(); if (editing) { evOnPatch.fire(); } else { evOnSync.fire(); } + wasEditing = Boolean(editing); }; APP.onFastChange = function (isFast) { APP.isFast = isFast; if (isFast) { + wasEditing = false; if (APP.hasChangedInterval) { window.clearInterval(APP.hasChangedInterval); } @@ -2562,6 +2564,7 @@ define([ sframeChan.event("EV_CORRUPTED_CACHE"); }; + var firstReady = true; config.onReady = function (info) { if (APP.realtime !== info.realtime) { APP.realtime = info.realtime; @@ -2671,8 +2674,12 @@ define([ setMyId(); oldHashes = JSON.parse(JSON.stringify(content.hashes)); initializing = false; - common.openPadChat(APP.onLocal); + // Only execute the following code the first time we call onReady + if (!firstReady) { return void setEditable(!readOnly); } + firstReady = false; + + common.openPadChat(APP.onLocal); if (!readOnly) { var cursors = {};