Skip to content

Commit

Permalink
🐛 Fix crash if document is opened too soon after creation
Browse files Browse the repository at this point in the history
  • Loading branch information
pajowu committed Nov 16, 2023
1 parent 177bfd5 commit fbcb002
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion frontend/src/editor/automerge_websocket_editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,11 @@ export function useAutomergeWebsocketEditor(
onInitialSyncComplete(editor);
setEditorAndInitialValue((oldValue) => {
oldValue?.editor.removeDocChangeListener(sendDocChange);
return { editor: editor, initialValue: JSON.parse(JSON.stringify(migratedDoc.children)) };
const initialValue =
migratedDoc.children !== undefined
? JSON.parse(JSON.stringify(migratedDoc.children))
: [];
return { editor: editor, initialValue: initialValue };
});
};

Expand Down

0 comments on commit fbcb002

Please sign in to comment.