From 5303e76ecef3cd78a15f4d9524665bf786fce787 Mon Sep 17 00:00:00 2001 From: yflory Date: Fri, 24 Feb 2017 18:55:41 +0100 Subject: [PATCH] Make sure the content is correctly applied in onReady --- www/common/cryptpad-common.js | 1 + www/pad/main.js | 14 +++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/www/common/cryptpad-common.js b/www/common/cryptpad-common.js index b2be4f5a1..80097e08c 100644 --- a/www/common/cryptpad-common.js +++ b/www/common/cryptpad-common.js @@ -812,6 +812,7 @@ define([ $('#' + LOADING).fadeOut(750, cb); }; common.errorLoadingScreen = function (error, transparent) { + if (!$('#' + LOADING).is(':visible')) { common.addLoadingScreen(); } $('.spinnerContainer').hide(); if (transparent) { $('#' + LOADING).css('opacity', 0.8); } $('#' + LOADING).find('p').html(error || Messages.error); diff --git a/www/pad/main.js b/www/pad/main.js index 48b2ef2d2..dc9d614a0 100644 --- a/www/pad/main.js +++ b/www/pad/main.js @@ -342,7 +342,7 @@ define([ var applyHjson = function (shjson) { var userDocStateDom = hjsonToDom(JSON.parse(shjson)); - if (!readOnly) { + if (!readOnly && !initializing) { userDocStateDom.setAttribute("contenteditable", "true"); // lol wtf } var patch = (DD).diff(inner, userDocStateDom); @@ -686,6 +686,18 @@ define([ }); } + if (!readOnly) { + var shjson2 = stringifyDOM(inner); + var hjson2 = JSON.parse(shjson2).slice(0,-1); + var hjson = JSON.parse(shjson).slice(0,-1); + if (stringify(hjson2) !== stringify(hjson)) { + console.log('err'); + console.error("shjson2 !== shjson"); + Cryptpad.errorLoadingScreen("Unable to display the content of that realtime session in your browser. Please try to reload that page."); // TODO translate + throw new Error(); + } + } + Cryptpad.getLastName(function (err, lastName) { console.log("Unlocking editor"); setEditable(true);