Fix merge problem
This commit is contained in:
@@ -375,29 +375,28 @@ const useLightrangeGraph = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 3. Process data
|
// 3. Process data
|
||||||
dataPromise.then((data) => {
|
dataPromise.then((result) => {
|
||||||
// 提取 rawGraph 数据
|
const state = useGraphStore.getState()
|
||||||
const rawGraphData = data?.rawGraph;
|
const data = result?.rawGraph;
|
||||||
|
|
||||||
// Assign colors based on entity_type *after* fetching
|
// Assign colors based on entity_type *after* fetching
|
||||||
if (rawGraphData && rawGraphData.nodes) {
|
if (data && data.nodes) {
|
||||||
rawGraphData.nodes.forEach(node => {
|
data.nodes.forEach(node => {
|
||||||
// Use entity_type instead of type
|
// Use entity_type instead of type
|
||||||
const nodeEntityType = node.properties?.entity_type as string | undefined;
|
const nodeEntityType = node.properties?.entity_type as string | undefined;
|
||||||
node.color = getNodeColorByType(nodeEntityType);
|
node.color = getNodeColorByType(nodeEntityType);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data?.is_truncated) {
|
if (result?.is_truncated) {
|
||||||
toast.info(t('graphPanel.dataIsTruncated', 'Graph data is truncated to Max Nodes'));
|
toast.info(t('graphPanel.dataIsTruncated', 'Graph data is truncated to Max Nodes'));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reset state
|
// Reset state
|
||||||
const state = useGraphStore.getState()
|
|
||||||
state.reset()
|
state.reset()
|
||||||
|
|
||||||
// Check if data is empty or invalid
|
// Check if data is empty or invalid
|
||||||
if (!rawGraphData || !rawGraphData.nodes || rawGraphData.nodes.length === 0) {
|
if (!data || !data.nodes || data.nodes.length === 0) {
|
||||||
// Create a graph with a single "Graph Is Empty" node
|
// Create a graph with a single "Graph Is Empty" node
|
||||||
const emptyGraph = new DirectedGraph();
|
const emptyGraph = new DirectedGraph();
|
||||||
|
|
||||||
@@ -438,12 +437,12 @@ const useLightrangeGraph = () => {
|
|||||||
console.log(`Graph data is empty, created graph with empty graph node. Auth error: ${isAuthError}`);
|
console.log(`Graph data is empty, created graph with empty graph node. Auth error: ${isAuthError}`);
|
||||||
} else {
|
} else {
|
||||||
// Create and set new graph
|
// Create and set new graph
|
||||||
const newSigmaGraph = createSigmaGraph(rawGraphData);
|
const newSigmaGraph = createSigmaGraph(data);
|
||||||
rawGraphData.buildDynamicMap();
|
data.buildDynamicMap();
|
||||||
|
|
||||||
// Set new graph data
|
// Set new graph data
|
||||||
state.setSigmaGraph(newSigmaGraph);
|
state.setSigmaGraph(newSigmaGraph);
|
||||||
state.setRawGraph(rawGraphData);
|
state.setRawGraph(data);
|
||||||
state.setGraphIsEmpty(false);
|
state.setGraphIsEmpty(false);
|
||||||
|
|
||||||
// Update last successful query label
|
// Update last successful query label
|
||||||
@@ -460,7 +459,7 @@ const useLightrangeGraph = () => {
|
|||||||
state.setIsFetching(false)
|
state.setIsFetching(false)
|
||||||
|
|
||||||
// Mark empty data as handled if data is empty and query label is empty
|
// Mark empty data as handled if data is empty and query label is empty
|
||||||
if ((!rawGraphData || !rawGraphData.nodes || rawGraphData.nodes.length === 0) && !currentQueryLabel) {
|
if ((!data || !data.nodes || data.nodes.length === 0) && !currentQueryLabel) {
|
||||||
emptyDataHandledRef.current = true;
|
emptyDataHandledRef.current = true;
|
||||||
}
|
}
|
||||||
}).catch((error) => {
|
}).catch((error) => {
|
||||||
@@ -508,9 +507,9 @@ const useLightrangeGraph = () => {
|
|||||||
// Process nodes to add required properties for RawNodeType
|
// Process nodes to add required properties for RawNodeType
|
||||||
const processedNodes: RawNodeType[] = [];
|
const processedNodes: RawNodeType[] = [];
|
||||||
for (const node of extendedGraph.nodes) {
|
for (const node of extendedGraph.nodes) {
|
||||||
// Get color based on entity_type using the helper function
|
// Generate random color values
|
||||||
const nodeEntityType = node.properties?.entity_type as string | undefined;
|
seedrandom(node.id, { global: true });
|
||||||
const color = getNodeColorByType(nodeEntityType);
|
const color = randomColor();
|
||||||
|
|
||||||
// Create a properly typed RawNodeType
|
// Create a properly typed RawNodeType
|
||||||
processedNodes.push({
|
processedNodes.push({
|
||||||
|
Reference in New Issue
Block a user