Skip to content

Commit d4194c5

Browse files
committed
fix(type_widgets/relation_map): map emptied when switching fast
1 parent 33a41d2 commit d4194c5

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

apps/client/src/widgets/type_widgets/relation_map/RelationMap.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,8 @@ async function useRelationData(noteId: string, mapData: MapData | undefined, map
211211
const [ inverseRelations, setInverseRelations ] = useState<RelationMapPostResponse["inverseRelations"]>();
212212

213213
async function refresh() {
214-
if (!noteIds) return;
214+
const api = mapApiRef.current;
215+
if (!noteIds || !api) return;
215216

216217
const data = await server.post<RelationMapPostResponse>("relation-map", { noteIds, relationMapNoteId: noteId });
217218
const relations: ClientRelation[] = [];
@@ -238,8 +239,8 @@ async function useRelationData(noteId: string, mapData: MapData | undefined, map
238239
}
239240

240241
setRelations(relations);
241-
mapApiRef.current?.loadRelations(relations);
242-
mapApiRef.current?.cleanupOtherNotes(Object.keys(data.noteTitles));
242+
api.loadRelations(relations);
243+
api.cleanupOtherNotes(Object.keys(data.noteTitles));
243244
}
244245

245246
useEffect(() => {

0 commit comments

Comments
 (0)