From 6e153dc85848bf3680280e5b842ca411a3655735 Mon Sep 17 00:00:00 2001 From: yflory Date: Fri, 25 Jan 2019 17:14:52 +0100 Subject: [PATCH] Handle server connection loss --- www/common/onlyoffice/inner.js | 18 ++++++++++++++++-- www/common/translations/messages.fr.js | 4 ++++ www/common/translations/messages.js | 11 +++++++---- 3 files changed, 27 insertions(+), 6 deletions(-) diff --git a/www/common/onlyoffice/inner.js b/www/common/onlyoffice/inner.js index 52d858de2..69f540db7 100644 --- a/www/common/onlyoffice/inner.js +++ b/www/common/onlyoffice/inner.js @@ -61,6 +61,7 @@ define([ var metadataMgr = common.getMetadataMgr(); var privateData = metadataMgr.getPrivateData(); var readOnly = false; + var offline = false; var config = {}; var content = { hashes: {}, @@ -451,7 +452,7 @@ define([ }); // Update current index var last = ooChannel.queue.pop(); - ooChannel.lastHash = last.hash; + if (last) { ooChannel.lastHash = last.hash; } ooChannel.cpIndex += ooChannel.queue.length; // Apply existing locks deleteOfflineLocks(); @@ -529,6 +530,7 @@ define([ locks: [content.locks[getId()]], excelAdditionalInfo: null }, null, function (err, hash) { + if (err) { return void console.error(err); } // Increment index and update latest hash ooChannel.cpIndex++; ooChannel.lastHash = hash; @@ -567,6 +569,7 @@ define([ handleAuth(obj, send); break; case "isSaveLock": + // TODO ping the server to check if we're online first? send({ type: "saveLock", saveLock: false @@ -738,6 +741,11 @@ define([ }; var setEditable = function (state) { + if (!state) { + try { + window.frames[0].editor.setViewModeDisconnect(true); + } catch (e) {} + } console.log(state); }; @@ -887,9 +895,14 @@ define([ config.onConnectionChange = function (info) { setEditable(info.state); if (info.state) { - initializing = true; UI.findOKButton().click(); + UI.confirm(Messages.oo_reconnect, function (yes) { + if (!yes) { return; } + common.gotoURL(); + }); } else { + offline = true; + UI.findOKButton().click(); UI.alert(Messages.common_connectionLost, undefined, true); } }; @@ -897,6 +910,7 @@ define([ cpNfInner = common.startRealtime(config); cpNfInner.onInfiniteSpinner(function () { + if (offline) { return; } setEditable(false); UI.confirm(Messages.realtime_unrecoverableError, function (yes) { if (!yes) { return; } diff --git a/www/common/translations/messages.fr.js b/www/common/translations/messages.fr.js index 33034d48f..7d86040b2 100644 --- a/www/common/translations/messages.fr.js +++ b/www/common/translations/messages.fr.js @@ -20,6 +20,7 @@ define(function () { out.type.media = "Média"; out.type.todo = "Todo"; out.type.contacts = "Contacts"; + out.type.sheet = 'Tableur (Beta)'; out.button_newpad = 'Nouveau document texte'; out.button_newcode = 'Nouvelle page de code'; @@ -327,6 +328,9 @@ define(function () { out.poll_comment_disabled = "Publiez ce sondage en utilisant le bouton ✓ afin d'activer les commentaires."; + // OnlyOffice + out.oo_reconnect = "La connexion au serveur est rétablie. Cliquez sur OK pour recharger la page et continuer l'édition."; + // Canvas out.canvas_clear = "Nettoyer"; out.canvas_delete = "Supprimer la sélection"; diff --git a/www/common/translations/messages.js b/www/common/translations/messages.js index 795c88d34..42a2f1b61 100644 --- a/www/common/translations/messages.js +++ b/www/common/translations/messages.js @@ -20,9 +20,9 @@ define(function () { out.type.media = 'Media'; out.type.todo = "Todo"; out.type.contacts = 'Contacts'; - out.type.oocell = 'OnlyOffice Cell'; - out.type.ooslide = 'OnlyOffice Slide'; - out.type.oodoc = 'OnlyOffice Doc'; + out.type.sheet = 'Spreadsheet (Beta)'; + //out.type.ooslide = 'OnlyOffice Slide'; + //out.type.oodoc = 'OnlyOffice Doc'; out.button_newpad = 'New Rich Text pad'; out.button_newcode = 'New Code pad'; @@ -332,6 +332,9 @@ define(function () { out.poll_comment_disabled = "Publish this poll using the ✓ button to enable the comments."; + // OnlyOffice + out.oo_reconnect = "The server connection is back. Click OK to reload and continue the edition."; + // Canvas out.canvas_clear = "Clear"; out.canvas_delete = "Delete selection"; @@ -1287,7 +1290,7 @@ define(function () { out.properties_confirmChange = "Are you sure? Changing the password will remove its history. Users without the new password will lose access to this pad"; out.properties_passwordSame = "New passwords must differ from the current one."; out.properties_passwordError = "An error occured while trying to change the password. Please try again."; - out.properties_passwordWarning = "The password was successfully changed but we were unable to update your CryptDrive with the new data. You may have to remove the old version of the pad manually.
Press OK to reload and update your acces rights."; + out.properties_passwordWarning = "The password was successfully changed but we were unable to update your CryptDrive with the new data. You may have to remove the old version of the pad manually.
Press OK to reload and update your access rights."; out.properties_passwordSuccess = "The password was successfully changed.
Press OK to reload and update your access rights."; out.properties_changePasswordButton = "Submit";