diff --git a/www/_socket/main.js b/www/_socket/main.js index c1e1833cc..71e3a4d39 100644 --- a/www/_socket/main.js +++ b/www/_socket/main.js @@ -174,14 +174,11 @@ define([ // apply patches, and try not to lose the cursor in the process! var applyHjson = function (shjson) { //setEditable(false); - console.log(now()); var userDocStateDom = Convert.hjson.to.dom(JSON.parse(shjson)); userDocStateDom.setAttribute("contenteditable", "true"); // lol wtf - console.log(now()); //assertStateMatches(); var patch = (DD).diff(inner, userDocStateDom); (DD).apply(inner, patch); - console.log(now()); // push back to the textarea so we get a userDocState //setEditable(true); }; diff --git a/www/_socket/realtime-input.js b/www/_socket/realtime-input.js index e40a19085..289f3d348 100644 --- a/www/_socket/realtime-input.js +++ b/www/_socket/realtime-input.js @@ -172,7 +172,7 @@ define([ // wrap up the reconnecting websocket with our additional stack logic var socket = makeWebsocket(websocketUrl); - var allMessages = []; + var allMessages = window.chainpad_allMessages = []; var isErrorState = false; var initializing = true; var recoverableErrorCount = 0; diff --git a/www/common/chainpad.js b/www/common/chainpad.js index 15b5505c6..e555cd55b 100644 --- a/www/common/chainpad.js +++ b/www/common/chainpad.js @@ -1033,13 +1033,13 @@ var handleMessage = ChainPad.handleMessage = function (realtime, msgStr) { // toApply.length-1 because we do not want to apply the new patch. for (var i = 0; i < toApply.length-1; i++) { + if (Common.PARANOIA) { + Common.assert(Sha.hex_sha256(authDocAtTimeOfPatch) === toApply[i].content.parentHash); + } if (typeof(toApply[i].content.inverseOf) === 'undefined') { toApply[i].content.inverseOf = Patch.invert(toApply[i].content, authDocAtTimeOfPatch); toApply[i].content.inverseOf.inverseOf = toApply[i].content; } - if (Common.PARANOIA) { - Common.assert(Sha.hex_sha256(authDocAtTimeOfPatch) === toApply[i].content.parentHash); - } authDocAtTimeOfPatch = Patch.apply(toApply[i].content, authDocAtTimeOfPatch); }