Send the initial state only if it is a new pad in /pad

This commit is contained in:
yflory 2017-02-27 14:29:38 +01:00
parent 66dc166936
commit d4bf7cf9aa

View File

@ -130,7 +130,7 @@ define([
$(inner).css({ $(inner).css({
color: '#fff', color: '#fff',
}); });
documentBody.innerHTML = Messages.initialState; //documentBody.innerHTML = Messages.initialState;
var cursor = window.cursor = Cursor(inner); var cursor = window.cursor = Cursor(inner);
@ -367,7 +367,8 @@ define([
var realtimeOptions = { var realtimeOptions = {
// provide initialstate... // provide initialstate...
initialState: stringifyDOM(inner) || '{}', //initialState: stringifyDOM(inner) || '{}',
initialState: '[]',
// the websocket URL // the websocket URL
websocketURL: Cryptpad.getWebsocketURL(), websocketURL: Cryptpad.getWebsocketURL(),
@ -675,6 +676,11 @@ define([
module.realtime = info.realtime; module.realtime = info.realtime;
var shjson = info.realtime.getUserDoc(); var shjson = info.realtime.getUserDoc();
var newPad = false;
if (shjson === '[]') { newPad = true; }
if (!newPad) {
applyHjson(shjson); applyHjson(shjson);
// Update the user list (metadata) from the hyperjson // Update the user list (metadata) from the hyperjson
@ -697,6 +703,10 @@ define([
throw new Error(); throw new Error();
} }
} }
} else {
updateMetadata(shjson);
documentBody.innerHTML = Messages.initialState;
}
Cryptpad.getLastName(function (err, lastName) { Cryptpad.getLastName(function (err, lastName) {
console.log("Unlocking editor"); console.log("Unlocking editor");