mirror of
https://git.mirrors.martin98.com/https://github.com/infiniflow/ragflow.git
synced 2025-08-14 22:05:53 +08:00
### What problem does this PR solve? fix: fixed the issue of error when opening the canvas #918 ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
parent
5a6a34cef9
commit
2ea696934b
@ -6,8 +6,7 @@ import {
|
|||||||
} from 'reactflow';
|
} from 'reactflow';
|
||||||
import useGraphStore from '../../store';
|
import useGraphStore from '../../store';
|
||||||
|
|
||||||
import { IFlow } from '@/interfaces/database/flow';
|
import { useFetchFlow } from '@/hooks/flow-hooks';
|
||||||
import { useQueryClient } from '@tanstack/react-query';
|
|
||||||
import { useMemo } from 'react';
|
import { useMemo } from 'react';
|
||||||
import styles from './index.less';
|
import styles from './index.less';
|
||||||
|
|
||||||
@ -44,12 +43,13 @@ export function ButtonEdge({
|
|||||||
};
|
};
|
||||||
|
|
||||||
// highlight the nodes that the workflow passes through
|
// highlight the nodes that the workflow passes through
|
||||||
const queryClient = useQueryClient();
|
// const queryClient = useQueryClient();
|
||||||
const flowDetail = queryClient.getQueryData<IFlow>(['flowDetail']);
|
// const flowDetail = queryClient.getQueryData<IFlow>(['flowDetail']);
|
||||||
|
const { data: flowDetail } = useFetchFlow();
|
||||||
|
|
||||||
const graphPath = useMemo(() => {
|
const graphPath = useMemo(() => {
|
||||||
// TODO: this will be called multiple times
|
// TODO: this will be called multiple times
|
||||||
const path = flowDetail?.dsl.path ?? [];
|
const path = flowDetail?.dsl?.path ?? [];
|
||||||
// The second to last
|
// The second to last
|
||||||
const previousGraphPath: string[] = path.at(-2) ?? [];
|
const previousGraphPath: string[] = path.at(-2) ?? [];
|
||||||
let graphPath: string[] = path.at(-1) ?? [];
|
let graphPath: string[] = path.at(-1) ?? [];
|
||||||
@ -59,13 +59,17 @@ export function ButtonEdge({
|
|||||||
graphPath = [previousLatestElement, ...graphPath];
|
graphPath = [previousLatestElement, ...graphPath];
|
||||||
}
|
}
|
||||||
return graphPath;
|
return graphPath;
|
||||||
}, [flowDetail?.dsl.path]);
|
}, [flowDetail.dsl?.path]);
|
||||||
|
|
||||||
const highlightStyle = useMemo(() => {
|
const highlightStyle = useMemo(() => {
|
||||||
const idx = graphPath.findIndex((x) => x === source);
|
const idx = graphPath.findIndex((x) => x === source);
|
||||||
if (idx !== -1 && graphPath[idx + 1] === target) {
|
if (idx !== -1) {
|
||||||
|
// The set of elements following source
|
||||||
|
const slicedGraphPath = graphPath.slice(idx + 1);
|
||||||
|
if (slicedGraphPath.some((x) => x === target)) {
|
||||||
return { strokeWidth: 2, stroke: 'red' };
|
return { strokeWidth: 2, stroke: 'red' };
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return {};
|
return {};
|
||||||
}, [source, target, graphPath]);
|
}, [source, target, graphPath]);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user