fix(type_widgets/relation_map): map emptied when switching fast

This commit is contained in:
Elian Doran 2025-11-09 12:38:12 +02:00
parent 33a41d2f86
commit d4194c503c
No known key found for this signature in database

View File

@ -211,7 +211,8 @@ async function useRelationData(noteId: string, mapData: MapData | undefined, map
const [ inverseRelations, setInverseRelations ] = useState<RelationMapPostResponse["inverseRelations"]>(); const [ inverseRelations, setInverseRelations ] = useState<RelationMapPostResponse["inverseRelations"]>();
async function refresh() { async function refresh() {
if (!noteIds) return; const api = mapApiRef.current;
if (!noteIds || !api) return;
const data = await server.post<RelationMapPostResponse>("relation-map", { noteIds, relationMapNoteId: noteId }); const data = await server.post<RelationMapPostResponse>("relation-map", { noteIds, relationMapNoteId: noteId });
const relations: ClientRelation[] = []; const relations: ClientRelation[] = [];
@ -238,8 +239,8 @@ async function useRelationData(noteId: string, mapData: MapData | undefined, map
} }
setRelations(relations); setRelations(relations);
mapApiRef.current?.loadRelations(relations); api.loadRelations(relations);
mapApiRef.current?.cleanupOtherNotes(Object.keys(data.noteTitles)); api.cleanupOtherNotes(Object.keys(data.noteTitles));
} }
useEffect(() => { useEffect(() => {