From 2bc6b58e3181676fca9051cf291156cb0e30edaf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Szymon=20K=C5=82os?= Date: Thu, 25 Apr 2019 16:04:22 +0200 Subject: [PATCH 1/2] Set timeout in case of editor inactivity MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Added 15s timeout what is enough even for a slow mobile client. If richdocuments doesn't receive Frame_Ready message then app will be closed. Signed-off-by: Szymon Kłos --- js/documents.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/js/documents.js b/js/documents.js index 3311baa7c..75b568430 100644 --- a/js/documents.js +++ b/js/documents.js @@ -141,6 +141,7 @@ Number.isInteger = Number.isInteger || function(value) { var documentsMain = { isEditorMode : false, isViewerMode: false, + isFrameReady: false, ready :false, fileName: null, baseName: null, @@ -637,6 +638,7 @@ var documentsMain = { } if (msg.MessageId === 'App_LoadingStatus') { if (msg.Values.Status === "Frame_Ready" ) { + documentsMain.isFrameReady = true; documentsMain.wopiClientFeatures = msg.Values.Features; documentsMain.overlay.documentOverlay('hide'); @@ -656,10 +658,24 @@ var documentsMain = { if (documentsMain.getFileList()) { documentsMain.getFileModel(); } + } else if (msg.Values.Status === "Failed") { + // Loading failed but editor shows the error + documentsMain.isFrameReady = true; + documentsMain.overlay.documentOverlay('hide'); + } else if (msg.Values.Status === "Timeout") { + // Timeout - no response from the editor + documentsMain.onClose(); } } }; window.addEventListener('message', editorInitListener, false); + + // In case of editor inactivity + setTimeout(function() { + if (!documentsMain.isFrameReady) { + editorInitListener({data: "{\"MessageId\": \"App_LoadingStatus\", \"Values\": {\"Status\": \"Timeout\"}}"}) + } + }, 15000); }); $('#loleafletframe').load(function(){ From 1091ae92d042ca293fc3025cdf906dba36843ff0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20H=C3=A4rtl?= Date: Mon, 29 Apr 2019 13:13:28 +0200 Subject: [PATCH 2/2] Show message if timeout occured MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Härtl --- js/documents.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/js/documents.js b/js/documents.js index 75b568430..1d1b98c71 100644 --- a/js/documents.js +++ b/js/documents.js @@ -665,6 +665,9 @@ var documentsMain = { } else if (msg.Values.Status === "Timeout") { // Timeout - no response from the editor documentsMain.onClose(); + parent.OC.Notification.showTemporary(t('richdocuments', 'Failed to connect to {productName}. Please try again later or contact your server administrator.', + { productName: oc_capabilities.richdocuments.productName} + )); } } };