Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
fix(relation_map): crash when valid JSON, but missing data (closes #8702)
Elian Dorana9ac11452dfe
diff --git a/apps/client/src/widgets/type_widgets/relation_map/RelationMap.tsx b/apps/client/src/widgets/type_widgets/relation_map/RelationMap.tsxindex 96ede43f7c..867fd44d39 100644--- a/apps/client/src/widgets/type_widgets/relation_map/RelationMap.tsx+++ b/apps/client/src/widgets/type_widgets/relation_map/RelationMap.tsx@@ -65,7 +65,7 @@ export default function RelationMap({ note, noteContext, ntxId, parentComponent};},onContentChange(content) {- let newData: MapData | null = null;+ let newData: Partial<MapData> | null = null;if (content) {try {@@ -75,7 +75,7 @@ export default function RelationMap({ note, noteContext, ntxId, parentComponent}}- if (!newData) {+ if (!newData || !newData.notes || !newData.transform) {newData = {notes: [],// it is important to have this exact value here so that initial transform is the same as this@@ -90,8 +90,8 @@ export default function RelationMap({ note, noteContext, ntxId, parentComponent};}- setData(newData);- mapApiRef.current = new RelationMapApi(note, newData, (newData, refreshUi) => {+ setData(newData as MapData);+ mapApiRef.current = new RelationMapApi(note, newData as MapData, (newData, refreshUi) => {if (refreshUi) {setData(newData);}