handle note.type changing

This commit is contained in:
Tom 2022-05-10 13:53:50 +02:00
parent c85f70e197
commit 3491e71084

View File

@ -159,8 +159,19 @@ export default class ExcalidrawTypeWidget extends TypeWidget {
* load saved content into excalidraw canvas
*/
else if (this.excalidrawRef.current && noteComplement.content) {
let content ={
elements: [],
appState: [],
files: [],
};
try {
const content = JSON.parse(noteComplement.content || "");
content = JSON.parse(noteComplement.content || "");
} catch(err) {
console.error("Error parsing content. Probably note.type changed",
"Starting with empty canvas"
, note, noteComplement, err);
}
const {elements, appState, files} = content;
@ -197,9 +208,6 @@ export default class ExcalidrawTypeWidget extends TypeWidget {
this.excalidrawRef.current.updateScene(sceneData);
this.excalidrawRef.current.addFiles(fileArray);
} catch(err) {
console.error("Error (note, noteComplement, err)", note, noteComplement, err);
}
}
// set initial scene version