Fetch all labels and graph data again on refresh
This commit is contained in:
@@ -93,9 +93,25 @@ const GraphLabels = () => {
|
||||
)
|
||||
|
||||
const handleRefresh = useCallback(() => {
|
||||
// Re-set the same label to trigger a refresh through useEffect
|
||||
const currentLabel = useSettingsStore.getState().queryLabel
|
||||
useSettingsStore.getState().setQueryLabel(currentLabel)
|
||||
// Reset labels fetch status to allow fetching labels again
|
||||
useGraphStore.getState().setLabelsFetchAttempted(false)
|
||||
|
||||
// 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 (
|
||||
|
@@ -229,7 +229,7 @@ const useLightrangeGraph = () => {
|
||||
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) {
|
||||
// Set flags
|
||||
fetchInProgressRef.current = true
|
||||
|
Reference in New Issue
Block a user