Set timeout in case of editor inactivity

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 <szymon.klos@collabora.com>
This commit is contained in:
Szymon Kłos 2019-04-25 16:04:22 +02:00
Родитель f78598917c
Коммит 2bc6b58e31
1 изменённых файлов: 16 добавлений и 0 удалений

Просмотреть файл

@ -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(){