Skip to content

Commit a6e360e

Browse files
committed
fix: handle sessionStorage retrieval and setGraphData in GraphVisualization component
Signed-off-by: Yash Bhesaniya <yashbhesaniya1999@gmail.com>
1 parent 16b8906 commit a6e360e

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

Project/frontend/src/components/Graph/index_visjs.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,12 +229,17 @@ const GraphVisualization: React.FC = () => {
229229

230230
useEffect(() => {
231231
const fetchGraphData = async () => {
232+
if (sessionStorage.getItem(fileId)) {
233+
setGraphData(JSON.parse(sessionStorage.getItem(fileId) as string));
234+
setIsLoading(false);
235+
return;
232236
try {
233237
const response = await fetch(
234238
`${import.meta.env.VITE_BACKEND_HOST}${VISUALIZE_API_PATH.replace(':fileId', fileId)}`,
235239
);
236240
const data = await response.json();
237241
setGraphData(data);
242+
sessionStorage.setItem(fileId, JSON.stringify(data));
238243

239244
// Get the list of unique topics
240245
const uniqueTopics = Array.from(

0 commit comments

Comments
 (0)