From aee4d443ef73c188ced877a860b29863fef53dcb Mon Sep 17 00:00:00 2001 From: yflory Date: Tue, 20 Apr 2021 17:47:28 +0200 Subject: [PATCH 01/12] Display the sync popup sooner in OO --- www/common/onlyoffice/inner.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/www/common/onlyoffice/inner.js b/www/common/onlyoffice/inner.js index eee9f6883..639e69d01 100644 --- a/www/common/onlyoffice/inner.js +++ b/www/common/onlyoffice/inner.js @@ -463,6 +463,9 @@ define([ }; fixSheets(); + if (!isLockedModal.modal) { + isLockedModal.modal = UI.openCustomModal(isLockedModal.content); + } ooChannel.ready = false; ooChannel.queue = []; data.callback = function () { @@ -2213,6 +2216,9 @@ define([ }; var loadCp = function (cp, keepQueue) { + if (!isLockedModal.modal) { + isLockedModal.modal = UI.openCustomModal(isLockedModal.content); + } loadLastDocument(cp, function () { var file = getFileType(); var type = common.getMetadataMgr().getPrivateData().ooType; @@ -2695,6 +2701,9 @@ define([ var reloadPopup = false; var checkNewCheckpoint = function () { + if (!isLockedModal.modal) { + isLockedModal.modal = UI.openCustomModal(isLockedModal.content); + } var lastCp = getLastCp(); loadLastDocument(lastCp, function (err) { console.error(err); From d3fd52d7215ca644a524d6f0b3c081be9df14e4b Mon Sep 17 00:00:00 2001 From: yflory Date: Fri, 23 Apr 2021 10:48:35 +0200 Subject: [PATCH 02/12] Handle corrupted cache in OO chainpad --- www/common/onlyoffice/inner.js | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/www/common/onlyoffice/inner.js b/www/common/onlyoffice/inner.js index 639e69d01..6f1ac6b2a 100644 --- a/www/common/onlyoffice/inner.js +++ b/www/common/onlyoffice/inner.js @@ -2528,6 +2528,18 @@ define([ toolbar.$drawer.append($properties); }; + var noCache = false; // Prevent reload loops + var onCorruptedCache = function () { + if (noCache) { + UI.errorLoadingScreen(Messages.unableToDisplay, false, function () { + common.gotoURL(''); + }); + } + noCache = true; + var sframeChan = common.getSframeChannel(); + sframeChan.event("EV_CORRUPTED_CACHE"); + }; + config.onReady = function (info) { if (APP.realtime !== info.realtime) { APP.realtime = info.realtime; @@ -2560,11 +2572,8 @@ define([ newDoc = !content.hashes || Object.keys(content.hashes).length === 0; } else if (!privateData.isNewFile) { // This is an empty doc but not a new file: error - // XXX clear cache before reloading - UI.errorLoadingScreen(Messages.unableToDisplay, false, function () { - common.gotoURL(''); - }); - throw new Error("Empty chainpad for a non-empty doc"); + onCorruptedCache(); + return void console.error("Empty chainpad for a non-empty doc"); } else { Title.updateTitle(Title.defaultTitle); } From c57400ab9c1a24c6ea419c1f00e9b319fcd2b602 Mon Sep 17 00:00:00 2001 From: yflory Date: Tue, 27 Apr 2021 13:54:19 +0200 Subject: [PATCH 03/12] Improve UX when maxUploadSize is reached in sheets --- www/common/onlyoffice/inner.js | 27 ++++++++++++++++++++++++++- www/common/sframe-common-file.js | 1 + 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/www/common/onlyoffice/inner.js b/www/common/onlyoffice/inner.js index 6f1ac6b2a..1a84d4a41 100644 --- a/www/common/onlyoffice/inner.js +++ b/www/common/onlyoffice/inner.js @@ -356,10 +356,32 @@ define([ } }; + Messages.oo_cantMigrate = "This sheet exceeds the maximum upload size and is too large to be migrated."; // XXX var onUploaded = function (ev, data, err) { content.saveLock = undefined; if (err) { console.error(err); + if (content.saveLock === myOOId) { delete content.saveLock; } // Unlock checkpoints + if (APP.migrateModal) { + try { getEditor().asc_setRestriction(true); } catch (e) {} + setEditable(true); + delete content.migration; + APP.migrateModal.closeModal(); + APP.onLocal(); + } + if (isLockedModal.modal && err === "TOO_LARGE") { + if (APP.migrate) { + UI.warn(Messages.oo_cantMigrate); + } + APP.cantCheckpoint = true; + isLockedModal.modal.closeModal(); + delete isLockedModal.modal; + if (content.saveLock === myOOId) { + delete content.saveLock; + } + APP.onLocal(); + return; + } return void UI.alert(Messages.oo_saveError); } // Get the last cp idx @@ -453,6 +475,7 @@ define([ }; var saveToServer = function () { + if (APP.cantCheckpoint) { return; } // TOO_LARGE var text = getContent(); var blob = new Blob([text], {type: 'plain/text'}); var file = getFileType(); @@ -479,6 +502,8 @@ define([ var noLogin = false; var makeCheckpoint = function (force) { + if (APP.cantCheckpoint) { return; } // TOO_LARGE + var locked = content.saveLock; var lastCp = getLastCp(); @@ -1388,7 +1413,7 @@ define([ h('span.fa.fa-spin.fa-spinner'), h('span', Messages.oo_sheetMigration_loading) ]); - UI.openCustomModal(UI.dialog.customModal(div, {buttons: []})); + APP.migrateModal = UI.openCustomModal(UI.dialog.customModal(div, {buttons: []})); makeCheckpoint(true); }); // DEPRECATED: from version 3, the queue is sent again during init diff --git a/www/common/sframe-common-file.js b/www/common/sframe-common-file.js index c7a66adb9..2a6f4fea3 100644 --- a/www/common/sframe-common-file.js +++ b/www/common/sframe-common-file.js @@ -133,6 +133,7 @@ define([ $pv.text(Messages.error); queue.inProgress = false; queue.next(); + if (config.onError) { config.onError("TOO_LARGE"); } return void UI.alert(Messages._getKey('upload_tooLargeBrief', [maxSizeStr])); } From ac875763601f92eff8eeb227e3675170d22a84ae Mon Sep 17 00:00:00 2001 From: yflory Date: Mon, 26 Apr 2021 13:23:59 +0200 Subject: [PATCH 04/12] Never store invalid OO checkpoints --- www/common/onlyoffice/inner.js | 12 ++++++++++++ www/common/sframe-common-outer.js | 10 ++++++++++ 2 files changed, 22 insertions(+) diff --git a/www/common/onlyoffice/inner.js b/www/common/onlyoffice/inner.js index 1a84d4a41..5a720a60c 100644 --- a/www/common/onlyoffice/inner.js +++ b/www/common/onlyoffice/inner.js @@ -477,6 +477,18 @@ define([ var saveToServer = function () { if (APP.cantCheckpoint) { return; } // TOO_LARGE var text = getContent(); + text = undefined; + if (!text) { + setEditable(false, true); + sframeChan.query('Q_CLEAR_CACHE_CHANNELS', [ + 'chainpad', + content.channel, + ], function () {}); + UI.alert(Messages.realtime_unrecoverableError, function () { + common.gotoURL(); + }); + return; + } var blob = new Blob([text], {type: 'plain/text'}); var file = getFileType(); blob.name = (metadataMgr.getMetadataLazy().title || file.doc) + '.' + file.type; diff --git a/www/common/sframe-common-outer.js b/www/common/sframe-common-outer.js index dde533e9f..7190fb997 100644 --- a/www/common/sframe-common-outer.js +++ b/www/common/sframe-common-outer.js @@ -1533,6 +1533,16 @@ define([ sframeChan.on('Q_CLEAR_CACHE', function (data, cb) { Utils.Cache.clear(cb); }); + sframeChan.on('Q_CLEAR_CACHE_CHANNELS', function (channels, cb) { + if (!Array.isArray(channels)) { return void cb({error: "NOT_AN_ARRAY"}); } + nThen(function (waitFor) { + channels.forEach(function (chan) { + if (chan === "chainpad") { chan = secret.channel; } + console.error(chan); + Utils.Cache.clearChannel(chan, waitFor()); + }); + }).nThen(cb); + }); sframeChan.on('Q_PIN_GET_USAGE', function (teamId, cb) { Cryptpad.isOverPinLimit(teamId, function (err, overLimit, data) { From d839481b72db7e0ab1a9795d01f038d1df9d52ed Mon Sep 17 00:00:00 2001 From: yflory Date: Tue, 27 Apr 2021 13:19:24 +0200 Subject: [PATCH 05/12] Remove debugging data --- www/common/onlyoffice/inner.js | 1 - 1 file changed, 1 deletion(-) diff --git a/www/common/onlyoffice/inner.js b/www/common/onlyoffice/inner.js index 5a720a60c..fa54dd80c 100644 --- a/www/common/onlyoffice/inner.js +++ b/www/common/onlyoffice/inner.js @@ -477,7 +477,6 @@ define([ var saveToServer = function () { if (APP.cantCheckpoint) { return; } // TOO_LARGE var text = getContent(); - text = undefined; if (!text) { setEditable(false, true); sframeChan.query('Q_CLEAR_CACHE_CHANNELS', [ From d903bf51a354a33d10ff15c92ba1ced695c60ced Mon Sep 17 00:00:00 2001 From: Weblate Date: Wed, 28 Apr 2021 13:51:50 +0200 Subject: [PATCH 06/12] Translated using Weblate (French) Currently translated at 99.7% (1183 of 1186 strings) Translation: CryptPad/App Translate-URL: http://weblate.cryptpad.fr/projects/cryptpad/app/fr/ --- www/common/translations/messages.fr.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/www/common/translations/messages.fr.json b/www/common/translations/messages.fr.json index cd3c86130..dab1481dd 100644 --- a/www/common/translations/messages.fr.json +++ b/www/common/translations/messages.fr.json @@ -1181,5 +1181,7 @@ "admin_maintenanceButton": "Planifier maintenance", "admin_maintenanceHint": "Planifier une maintenance sur cette instance et avertir tous les utilisateurs. Limité à une maintenance active à la fois.", "admin_maintenanceTitle": "Maintenance", - "admin_cat_broadcast": "Annonces" + "admin_cat_broadcast": "Annonces", + "oo_cantMigrate": "Ce tableur dépasse la taille maximale de téléchargement et est trop grand pour être mis à jour.", + "footer_roadmap": "Feuille de route" } From 102c36165d0d4fde16e96dfb5a8abce22e2439c3 Mon Sep 17 00:00:00 2001 From: Weblate Date: Wed, 28 Apr 2021 13:51:50 +0200 Subject: [PATCH 07/12] Translated using Weblate (German) Currently translated at 99.9% (1184 of 1185 strings) Translation: CryptPad/App Translate-URL: http://weblate.cryptpad.fr/projects/cryptpad/app/de/ --- www/common/translations/messages.de.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/common/translations/messages.de.json b/www/common/translations/messages.de.json index c7d28db09..f01a473e2 100644 --- a/www/common/translations/messages.de.json +++ b/www/common/translations/messages.de.json @@ -541,7 +541,7 @@ "four04_pageNotFound": "Wir konnten die Seite, die du angefordert hast, nicht finden.", "header_logoTitle": "Zu deinem CryptDrive", "header_homeTitle": "Zur CryptPad-Hauptseite", - "help_genericMore": "Erfahre mehr über die Nutzung von CryptPad, indem du unsere Documentation liest.", + "help_genericMore": "Erfahre mehr über die Nutzung von CryptPad, indem du unsere Dokumentation liest.", "driveReadmeTitle": "Was ist CryptPad?", "edit": "Bearbeiten", "view": "Ansehen", From d39a2db7346b1f3a489593100444f055b4a5b84c Mon Sep 17 00:00:00 2001 From: Weblate Date: Wed, 28 Apr 2021 13:51:50 +0200 Subject: [PATCH 08/12] Translated using Weblate (English) Currently translated at 100.0% (1186 of 1186 strings) Translation: CryptPad/App Translate-URL: http://weblate.cryptpad.fr/projects/cryptpad/app/en/ --- www/common/translations/messages.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/www/common/translations/messages.json b/www/common/translations/messages.json index 18c6feb8a..a725cb012 100644 --- a/www/common/translations/messages.json +++ b/www/common/translations/messages.json @@ -1185,5 +1185,6 @@ "settings_deleteWarning": "Warning: you are currently subscribed to a premium plan (paid or given by another user). Please cancel your plan before deleting your account as will not be possible without contacting support once your account is deleted.", "settings_deleteContinue": "Delete my account", "settings_deleteSubscription": "Manage my subscription", - "footer_roadmap": "Roadmap" + "footer_roadmap": "Roadmap", + "oo_cantMigrate": "This sheet exceeds the maximum upload size and is too large to be migrated." } From b812bc27f622bc57693fdb7d8262575d7e7b4e1a Mon Sep 17 00:00:00 2001 From: ansuz Date: Wed, 28 Apr 2021 17:25:04 +0530 Subject: [PATCH 09/12] remove hardcoded translation --- www/common/onlyoffice/inner.js | 1 - 1 file changed, 1 deletion(-) diff --git a/www/common/onlyoffice/inner.js b/www/common/onlyoffice/inner.js index fa54dd80c..e99787d9e 100644 --- a/www/common/onlyoffice/inner.js +++ b/www/common/onlyoffice/inner.js @@ -356,7 +356,6 @@ define([ } }; - Messages.oo_cantMigrate = "This sheet exceeds the maximum upload size and is too large to be migrated."; // XXX var onUploaded = function (ev, data, err) { content.saveLock = undefined; if (err) { From 9d6d5b3ed317f6408b26937c5c79c9e884c5ac19 Mon Sep 17 00:00:00 2001 From: yflory Date: Tue, 27 Apr 2021 13:55:03 +0200 Subject: [PATCH 10/12] lint compliance --- www/common/onlyoffice/inner.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/www/common/onlyoffice/inner.js b/www/common/onlyoffice/inner.js index e99787d9e..fcffadb52 100644 --- a/www/common/onlyoffice/inner.js +++ b/www/common/onlyoffice/inner.js @@ -356,6 +356,14 @@ define([ } }; + // Add a lock + var isLockedModal = { + content: UI.dialog.customModal(h('div.cp-oo-x2tXls', [ + h('span.fa.fa-spin.fa-spinner'), + h('span', Messages.oo_isLocked) + ])) + }; + var onUploaded = function (ev, data, err) { content.saveLock = undefined; if (err) { @@ -443,14 +451,6 @@ define([ }; APP.FM = common.createFileManager(fmConfig); - // Add a lock - var isLockedModal = { - content: UI.dialog.customModal(h('div.cp-oo-x2tXls', [ - h('span.fa.fa-spin.fa-spinner'), - h('span', Messages.oo_isLocked) - ])) - }; - var resetData = function (blob, type) { // If a read-only refresh popup was planned, abort it delete APP.refreshPopup; From 1d47d3d94ef5b1ed0ae88a25be42705a6d8929e4 Mon Sep 17 00:00:00 2001 From: yflory Date: Fri, 23 Apr 2021 11:12:45 +0200 Subject: [PATCH 11/12] Prevent type error from CkEditor widgets --- www/pad/inner.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/www/pad/inner.js b/www/pad/inner.js index b442de0b5..c78811b07 100644 --- a/www/pad/inner.js +++ b/www/pad/inner.js @@ -984,7 +984,11 @@ define([ displayMediaTags(framework, inner, mediaTagMap); // MEDIATAG: Initialize mediatag widgets inserted in the document by other users - editor.widgets.checkWidgets(); + try { + editor.widgets.checkWidgets(); + } catch (e) { + console.error(e); + } if (framework.isReadOnly()) { var $links = $inner.find('a'); From 980a2369007a3b6eeb4de105bfcf1cf13e3444ec Mon Sep 17 00:00:00 2001 From: yflory Date: Tue, 27 Apr 2021 14:51:11 +0200 Subject: [PATCH 12/12] Prevent parse errors in sframe-common-outer --- www/common/sframe-common-outer.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/www/common/sframe-common-outer.js b/www/common/sframe-common-outer.js index 7190fb997..d24f62f9d 100644 --- a/www/common/sframe-common-outer.js +++ b/www/common/sframe-common-outer.js @@ -44,8 +44,8 @@ define([ // loading screen setup. var done = waitFor(); var onMsg = function (msg) { - var data = JSON.parse(msg.data); - if (data.q !== 'READY') { return; } + var data = typeof(msg.data) === "string" ? JSON.parse(msg.data) : msg.data; + if (!data || data.q !== 'READY') { return; } window.removeEventListener('message', onMsg); var _done = done; done = function () { }; @@ -182,8 +182,8 @@ define([ }; var whenReady = waitFor(function (msg) { if (msg.source !== iframe) { return; } - var data = JSON.parse(msg.data); - if (!data.txid) { return; } + var data = typeof(msg.data) === "string" ? JSON.parse(msg.data) : msg.data; + if (!data || !data.txid) { return; } // Remove the listener once we've received the READY message window.removeEventListener('message', whenReady); // Answer with the requested data