aboutsummaryrefslogtreecommitdiffstats
path: root/view
diff options
context:
space:
mode:
authorzotlabs <mike@macgirvin.com>2016-11-01 21:39:49 -0700
committerzotlabs <mike@macgirvin.com>2016-11-01 21:39:49 -0700
commit055d55b71b2430850f758378513e75e69fa27745 (patch)
treea79ff3ad8ae8937e89faae1700be071fc9c1e4a2 /view
parentfa8cb40af0457ed9ad418be2ba64dc221cbaa842 (diff)
downloadvolse-hubzilla-055d55b71b2430850f758378513e75e69fa27745.tar.gz
volse-hubzilla-055d55b71b2430850f758378513e75e69fa27745.tar.bz2
volse-hubzilla-055d55b71b2430850f758378513e75e69fa27745.zip
retry liveupdate up to 10 times if we receive incomplete/truncated html data.
Diffstat (limited to 'view')
-rw-r--r--view/js/main.js23
1 files changed, 22 insertions, 1 deletions
diff --git a/view/js/main.js b/view/js/main.js
index 5435dfd87..6c7e90807 100644
--- a/view/js/main.js
+++ b/view/js/main.js
@@ -249,7 +249,7 @@ var divmore_height = 400;
var last_filestorage_id = null;
var mediaPlaying = false;
var contentHeightDiff = 0;
-
+var liveRecurse = 0;
$(function() {
$.ajaxSetup({cache: false});
@@ -762,6 +762,27 @@ function liveUpdate() {
var dstart = new Date();
console.log('LOADING data...');
$.get(update_url, function(data) {
+
+ // on shared hosts occasionally the live update process will be killed
+ // leaving an incomplete HTML structure, which leads to conversations getting
+ // truncated and the page messed up if all the divs aren't closed. We will try
+ // again and give up if we can't get a valid HTML response after 10 tries.
+
+ if((data.indexOf("<html>") != (-1)) && (data.indexOf("</html>") == (-1))) {
+ console.log('Incomplete data. Reloading');
+ in_progress = false;
+ liveRecurse ++;
+ if(liveRecurse < 10) {
+ liveUpdate();
+ }
+ else {
+ console.log('Incomplete data. Too many attempts. Giving up.');
+ }
+ }
+
+ // else data was valid - reset the recursion counter
+ liveRecurse = 0;
+
var dready = new Date();
console.log('DATA ready in: ' + (dready - dstart)/1000 + ' seconds.');