Wait till page is rendered

There's a race condition here between page being rendered with
all the document(s) information and showing the editor to the
user. The later requires the former as it uses data rendered into
the page.

In most cases, former is quick enough and we do not see any
problems, but in some cases, mostly when the server is responding
very slowly, it will lag behind the later causing the editor to
be shown before data is rendered into the page leading to '404
Object not found'.

This should, hopefully, avoid such cases.
pull/1/head
Pranav Kant 8 years ago
parent c80a31ebe0
commit c084533efb

@ -17,6 +17,7 @@ $.widget('oc.documentGrid', {
jQuery.when(this._load(fileId))
.then(function(){
that._render();
documentsMain.renderComplete = true;
});
},
@ -189,6 +190,7 @@ var documentsMain = {
loadError : false,
loadErrorMessage : '',
loadErrorHint : '',
renderComplete: false, // false till page is rendered with all required data about the document(s)
toolbar : '<div id="ocToolbar"><div id="ocToolbarInside"></div><span id="toolbar" class="claro"></span></div>',
returnToDir : null, // directory where we started from in the 'Files' app
@ -375,6 +377,12 @@ var documentsMain = {
return;
}
if (!documentsMain.renderComplete) {
setTimeout(function() { documentsMain.UI.showEditor(title); }, 500);
console.log('Waiting for page to render ...');
return;
}
$(document.body).addClass("claro");
$(document.body).prepend(documentsMain.UI.container);

Loading…
Cancel
Save