diff options
author | Pranav Kant <pranavk@collabora.co.uk> | 2016-06-29 19:15:42 +0300 |
---|---|---|
committer | Pranav Kant <pranavk@collabora.co.uk> | 2016-06-29 19:33:01 +0300 |
commit | c084533efb4bac37bb46472066ccbcfc052610e5 (patch) | |
tree | a0acd677351f7082604dacd67b13b839d104f70a /js | |
parent | c80a31ebe04bb41a7a7d6dd975a7fac2b8ed3339 (diff) |
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.
Diffstat (limited to 'js')
-rw-r--r-- | js/documents.js | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/js/documents.js b/js/documents.js index 66dc6722..ee578bc8 100644 --- a/js/documents.js +++ b/js/documents.js @@ -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); |