Throw an error when trying to open a document with the wrong app

pull/1/head
yflory 8 years ago
parent ad82a275bc
commit 7d6e15e465

@ -552,9 +552,15 @@ define([
var userDoc = module.realtime.getUserDoc(); var userDoc = module.realtime.getUserDoc();
var newDoc = ""; var newDoc = "";
if(userDoc !== "") { if(userDoc !== "") {
var hjson = JSON.parse(userDoc); var hjson = JSON.parse(userDoc);
if (typeof (hjson) !== 'object' || Array.isArray(hjson)) {
throw new Error("That realtime document is not compatible with the Code app");
}
newDoc = hjson.content; newDoc = hjson.content;
if (hjson.highlightMode) { if (hjson.highlightMode) {

@ -630,6 +630,10 @@ define([
var hjson = JSON.parse(userDoc); var hjson = JSON.parse(userDoc);
newDoc = hjson.content; newDoc = hjson.content;
if (typeof (hjson) !== 'object' || Array.isArray(hjson)) {
throw new Error("That realtime document is not compatible with the Slide app");
}
if (hjson.highlightMode) { if (hjson.highlightMode) {
setMode(hjson.highlightMode, module.$language); setMode(hjson.highlightMode, module.$language);
} }

Loading…
Cancel
Save