Skip to content

Commit c7fcd10

Browse files
gkorlandCopilot
andcommitted
fix(frontend): pass isFetchingGraph prop to CodeGraph components
Add isFetchingGraph state to App.tsx and pass it to both desktop and mobile CodeGraph components. Set true on fetch start, false in finally block so the loading spinner renders correctly. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 1b62f19 commit c7fcd10

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

app/src/App.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ export default function App() {
9090
const [carouselApi, setCarouselApi] = useState<CarouselApi>()
9191
const [zoomedNodes, setZoomedNodes] = useState<Node[]>([])
9292
const [hasHiddenElements, setHasHiddenElements] = useState(false);
93+
const [isFetchingGraph, setIsFetchingGraph] = useState(false);
9394

9495
useEffect(() => {
9596
if (path?.start?.id && path?.end?.id) {
@@ -153,6 +154,7 @@ export default function App() {
153154
}
154155

155156
async function onFetchGraph(graphName: string) {
157+
setIsFetchingGraph(true);
156158
try {
157159
const result = await fetch(`/api/graph_entities?repo=${prepareArg(graphName)}`, {
158160
method: 'GET',
@@ -186,6 +188,8 @@ export default function App() {
186188
title: "Uh oh! Something went wrong.",
187189
description: "Failed to load repository graph. Please try again.",
188190
})
191+
} finally {
192+
setIsFetchingGraph(false);
189193
}
190194
}
191195

@@ -527,6 +531,7 @@ export default function App() {
527531
options={options}
528532
setOptions={setOptions}
529533
onFetchGraph={onFetchGraph}
534+
isFetchingGraph={isFetchingGraph}
530535
onFetchNode={onFetchNode}
531536
setPath={setPath}
532537
isShowPath={!!path}
@@ -654,6 +659,7 @@ export default function App() {
654659
options={options}
655660
setOptions={setOptions}
656661
onFetchGraph={onFetchGraph}
662+
isFetchingGraph={isFetchingGraph}
657663
onFetchNode={onFetchNode}
658664
setPath={setPath}
659665
isShowPath={!!path}

0 commit comments

Comments
 (0)