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,27 +676,36 @@ define([
module.realtime = info.realtime; module.realtime = info.realtime;
var shjson = info.realtime.getUserDoc(); var shjson = info.realtime.getUserDoc();
applyHjson(shjson);
// Update the user list (metadata) from the hyperjson var newPad = false;
updateMetadata(shjson); if (shjson === '[]') { newPad = true; }
if (Visible.isSupported()) { if (!newPad) {
Visible.onChange(function (yes) { applyHjson(shjson);
if (yes) { unnotify(); }
});
}
if (!readOnly) { // Update the user list (metadata) from the hyperjson
var shjson2 = stringifyDOM(inner); updateMetadata(shjson);
var hjson2 = JSON.parse(shjson2).slice(0,-1);
var hjson = JSON.parse(shjson).slice(0,-1); if (Visible.isSupported()) {
if (stringify(hjson2) !== stringify(hjson)) { Visible.onChange(function (yes) {
console.log('err'); if (yes) { unnotify(); }
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();
} }
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();
}
}
} else {
updateMetadata(shjson);
documentBody.innerHTML = Messages.initialState;
} }
Cryptpad.getLastName(function (err, lastName) { Cryptpad.getLastName(function (err, lastName) {