From 0282f91aa0953e4bde4adc9210f821eab59869f2 Mon Sep 17 00:00:00 2001 From: Alex Boyd Date: Wed, 28 Aug 2024 20:21:42 -0400 Subject: [PATCH] Temp fix (page refresh) to reloading, need to set up subscriptions --- react/src/components/SideBar.tsx | 24 ++++++++++++++----- .../components/graph/InvestigationGraph.tsx | 9 ++++--- .../src/components/graph/nodes/AuthorNode.tsx | 10 ++++++-- react/src/components/graph/nodes/NoteNode.tsx | 2 +- .../components/graph/nodes/WorkDetails.tsx | 14 ++++++++--- react/src/components/graph/nodes/WorkNode.tsx | 22 +++++++++++++---- 6 files changed, 60 insertions(+), 21 deletions(-) diff --git a/react/src/components/SideBar.tsx b/react/src/components/SideBar.tsx index a05e0f3..0ccf529 100644 --- a/react/src/components/SideBar.tsx +++ b/react/src/components/SideBar.tsx @@ -31,11 +31,17 @@ function SideBar() { doi: doiSearch, investigationId: investigationId, }, - onCompleted: (data) => {}, + onCompleted: (data) => { + { + { + window.location.reload(); + } + } + }, onError: (data) => { console.log(data); }, - refetchQueries: [USE_INVESTIGATION_GRAPH], + // refetchQueries: [USE_INVESTIGATION_GRAPH], }); let doiInputHandler = (e) => { @@ -55,11 +61,17 @@ function SideBar() { bodyText: noteBodyText, investigationId: investigationId, }, - onCompleted: (data) => {}, + onCompleted: (data) => { + { + { + window.location.reload(); + } + } + }, onError: (data) => { console.log(data); }, - refetchQueries: [USE_INVESTIGATION_GRAPH], + // refetchQueries: [USE_INVESTIGATION_GRAPH], }); return ( @@ -82,12 +94,12 @@ function SideBar() { > */} - - + */} ); } diff --git a/react/src/components/graph/InvestigationGraph.tsx b/react/src/components/graph/InvestigationGraph.tsx index cb82a4c..cab6528 100644 --- a/react/src/components/graph/InvestigationGraph.tsx +++ b/react/src/components/graph/InvestigationGraph.tsx @@ -31,7 +31,6 @@ function InvestigationGraph({ [] ); - const initialNodes = []; const initialEdges = []; @@ -70,20 +69,21 @@ function InvestigationGraph({ for (let i = 0; i <= workEdges.length - 1; i++) { if (workEdges[i].visible) { initialEdges.push({ - source: `work-${workEdges[i].citationNode.id}`, - target: `work-${workEdges[i].referenceNode.id}`, + target: `work-${workEdges[i].citationNode.id}`, + source: `work-${workEdges[i].referenceNode.id}`, id: `workedge-${workEdges[i].id}`, label: "citation/reference", style: { strokeWidth: 2, stroke: "#FF0072", }, - markerStart: { + markerEnd: { type: MarkerType.ArrowClosed, width: 20, height: 20, color: "#FF0072", }, + animated: true, }); } } @@ -114,7 +114,6 @@ function InvestigationGraph({ edges={edges} onNodesChange={onNodesChange} onEdgesChange={onEdgesChange} - // onConnect={onConnect} nodeTypes={nodeTypes} nodesDraggable={true} fitView diff --git a/react/src/components/graph/nodes/AuthorNode.tsx b/react/src/components/graph/nodes/AuthorNode.tsx index e29303b..33234ab 100644 --- a/react/src/components/graph/nodes/AuthorNode.tsx +++ b/react/src/components/graph/nodes/AuthorNode.tsx @@ -25,11 +25,17 @@ function AuthorNode({ data }) { const [addAuthorWorks] = useMutation(ADD_AUTHOR_WORKS, { errorPolicy: "ignore", - onCompleted: (data) => {}, + onCompleted: (data) => { + { + { + window.location.reload(); + } + } + }, onError: (data) => { console.log(data); }, - refetchQueries: [USE_INVESTIGATION_GRAPH], + // refetchQueries: [USE_INVESTIGATION_GRAPH], }); useEffect(() => { diff --git a/react/src/components/graph/nodes/NoteNode.tsx b/react/src/components/graph/nodes/NoteNode.tsx index 96660a9..4d6a8f9 100644 --- a/react/src/components/graph/nodes/NoteNode.tsx +++ b/react/src/components/graph/nodes/NoteNode.tsx @@ -26,7 +26,7 @@ function NoteNode({ investigationId: investigationId, noteNodeId: id }, - refetchQueries: [USE_INVESTIGATION_GRAPH] // this doesn't seem to work for trigger refresh of graph, not sure why? It works in root node + // refetchQueries: [USE_INVESTIGATION_GRAPH] // this doesn't seem to work for trigger refresh of graph, not sure why? It works in root node }) return ( diff --git a/react/src/components/graph/nodes/WorkDetails.tsx b/react/src/components/graph/nodes/WorkDetails.tsx index 9234ffd..7cd22d6 100644 --- a/react/src/components/graph/nodes/WorkDetails.tsx +++ b/react/src/components/graph/nodes/WorkDetails.tsx @@ -33,11 +33,17 @@ function WorkDetails({ const { investigationId } = useParams(); const [addAuthor] = useMutation(CREATE_AUTHOR_NODE, { errorPolicy: "ignore", - onCompleted: (data) => {}, + onCompleted: (data) => { + { + { + window.location.reload(); + } + } + }, onError: (data) => { console.log(data); }, - refetchQueries: [USE_INVESTIGATION_GRAPH], + // refetchQueries: [USE_INVESTIGATION_GRAPH], }); return ( @@ -50,7 +56,9 @@ function WorkDetails({ > {abstract} diff --git a/react/src/components/graph/nodes/WorkNode.tsx b/react/src/components/graph/nodes/WorkNode.tsx index 4b5b004..90ba04f 100644 --- a/react/src/components/graph/nodes/WorkNode.tsx +++ b/react/src/components/graph/nodes/WorkNode.tsx @@ -57,7 +57,14 @@ function WorkNode({ data }) { openalexId: data.workData.work.openalexId, investigationId: investigationId, }, - refetchQueries: [USE_INVESTIGATION_GRAPH], + onCompleted: (data) => { + { + { + window.location.reload(); + } + } + }, + // refetchQueries: [USE_INVESTIGATION_GRAPH], }); const [addCitations] = useMutation(ADD_CITATIONS, { @@ -65,7 +72,14 @@ function WorkNode({ data }) { openalexId: data.workData.work.openalexId, investigationId: investigationId, }, - refetchQueries: [USE_INVESTIGATION_GRAPH], + onCompleted: (data) => { + { + { + window.location.reload(); + } + } + }, + // refetchQueries: [USE_INVESTIGATION_GRAPH], }); useEffect(() => { @@ -84,8 +98,8 @@ function WorkNode({ data }) { }} ref={noderef} > - - + +