Fetch all labels and graph data again on refresh
This commit is contained in:
@@ -93,9 +93,25 @@ const GraphLabels = () => {
|
|||||||
)
|
)
|
||||||
|
|
||||||
const handleRefresh = useCallback(() => {
|
const handleRefresh = useCallback(() => {
|
||||||
// Re-set the same label to trigger a refresh through useEffect
|
// Reset labels fetch status to allow fetching labels again
|
||||||
const currentLabel = useSettingsStore.getState().queryLabel
|
useGraphStore.getState().setLabelsFetchAttempted(false)
|
||||||
useSettingsStore.getState().setQueryLabel(currentLabel)
|
|
||||||
|
// Reset graph data fetch status directly, not depending on allDatabaseLabels changes
|
||||||
|
useGraphStore.getState().setGraphDataFetchAttempted(false)
|
||||||
|
|
||||||
|
// Fetch all labels again
|
||||||
|
useGraphStore.getState().fetchAllDatabaseLabels()
|
||||||
|
.then(() => {
|
||||||
|
// Trigger a graph data reload by changing the query label back and forth
|
||||||
|
const currentLabel = useSettingsStore.getState().queryLabel
|
||||||
|
useSettingsStore.getState().setQueryLabel('')
|
||||||
|
setTimeout(() => {
|
||||||
|
useSettingsStore.getState().setQueryLabel(currentLabel)
|
||||||
|
}, 0)
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
console.error('Failed to refresh labels:', error)
|
||||||
|
})
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@@ -229,7 +229,7 @@ const useLightrangeGraph = () => {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only fetch data when graphDataFetchAttempted is false
|
// Only fetch data when graphDataFetchAttempted is false (avoids re-fetching on vite dev mode)
|
||||||
if (!isFetching && !useGraphStore.getState().graphDataFetchAttempted) {
|
if (!isFetching && !useGraphStore.getState().graphDataFetchAttempted) {
|
||||||
// Set flags
|
// Set flags
|
||||||
fetchInProgressRef.current = true
|
fetchInProgressRef.current = true
|
||||||
|
Reference in New Issue
Block a user