Limit the search scope to labels in the current subgraph

- Decouple datasource label selection from the search input field
- Improve label selection handling logic
This commit is contained in:
yangdx
2025-03-13 00:20:53 +08:00
parent fa1e7b13a1
commit 727b137506
3 changed files with 45 additions and 24 deletions

View File

@@ -169,6 +169,11 @@ const useLightrangeGraph = () => {
const minDegree = useSettingsStore.use.graphMinDegree()
const isFetching = useGraphStore.use.isFetching()
// Fetch all database labels on mount
useEffect(() => {
useGraphStore.getState().fetchAllDatabaseLabels()
}, [])
// Use ref to track fetch status
const fetchStatusRef = useRef<Record<string, boolean>>({});
@@ -222,7 +227,7 @@ const useLightrangeGraph = () => {
state.setSigmaGraph(newSigmaGraph)
state.setRawGraph(data)
// Extract labels from graph data
// Extract labels from current graph data
if (data) {
const labelSet = new Set<string>();
for (const node of data.nodes) {
@@ -241,6 +246,9 @@ const useLightrangeGraph = () => {
// Ensure * is there eventhough there is no graph data
state.setGraphLabels(['*']);
}
// Fetch all database labels after graph update
state.fetchAllDatabaseLabels();
if (!data) {
// If data is invalid, remove the fetch flag to allow retry
delete fetchStatusRef.current[fetchKey];