Fix merge conflicts
This commit is contained in:
@@ -363,7 +363,7 @@ const useLightrangeGraph = () => {
|
|||||||
const currentMaxNodes = maxNodes
|
const currentMaxNodes = maxNodes
|
||||||
|
|
||||||
// Declare a variable to store data promise
|
// Declare a variable to store data promise
|
||||||
let dataPromise: Promise<RawGraph | null>;
|
let dataPromise: Promise<{ rawGraph: RawGraph | null; is_truncated: boolean | undefined } | null>;
|
||||||
|
|
||||||
// 1. If query label is not empty, use fetchGraph
|
// 1. If query label is not empty, use fetchGraph
|
||||||
if (currentQueryLabel) {
|
if (currentQueryLabel) {
|
||||||
@@ -376,28 +376,28 @@ const useLightrangeGraph = () => {
|
|||||||
|
|
||||||
// 3. Process data
|
// 3. Process data
|
||||||
dataPromise.then((data) => {
|
dataPromise.then((data) => {
|
||||||
|
// 提取 rawGraph 数据
|
||||||
|
const rawGraphData = data?.rawGraph;
|
||||||
|
|
||||||
// Assign colors based on entity_type *after* fetching
|
// Assign colors based on entity_type *after* fetching
|
||||||
if (data && data.nodes) {
|
if (rawGraphData && rawGraphData.nodes) {
|
||||||
data.nodes.forEach(node => {
|
rawGraphData.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);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const state = useGraphStore.getState()
|
if (data?.is_truncated) {
|
||||||
const data = result?.rawGraph;
|
|
||||||
|
|
||||||
// Check 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 (!data || !data.nodes || data.nodes.length === 0) {
|
if (!rawGraphData || !rawGraphData.nodes || rawGraphData.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 +438,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(data);
|
const newSigmaGraph = createSigmaGraph(rawGraphData);
|
||||||
data.buildDynamicMap();
|
rawGraphData.buildDynamicMap();
|
||||||
|
|
||||||
// Set new graph data
|
// Set new graph data
|
||||||
state.setSigmaGraph(newSigmaGraph);
|
state.setSigmaGraph(newSigmaGraph);
|
||||||
state.setRawGraph(data);
|
state.setRawGraph(rawGraphData);
|
||||||
state.setGraphIsEmpty(false);
|
state.setGraphIsEmpty(false);
|
||||||
|
|
||||||
// Update last successful query label
|
// Update last successful query label
|
||||||
@@ -460,7 +460,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 ((!data || !data.nodes || data.nodes.length === 0) && !currentQueryLabel) {
|
if ((!rawGraphData || !rawGraphData.nodes || rawGraphData.nodes.length === 0) && !currentQueryLabel) {
|
||||||
emptyDataHandledRef.current = true;
|
emptyDataHandledRef.current = true;
|
||||||
}
|
}
|
||||||
}).catch((error) => {
|
}).catch((error) => {
|
||||||
|
Reference in New Issue
Block a user