mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-08-02 22:07:31 +08:00
Fix: The save interface is continuously called without any operation being performed on the agent page. (#17576)
This commit is contained in:
@@ -444,7 +444,10 @@ export const useResetAgent = () => {
|
||||
return { data, loading, resetAgent: mutateAsync };
|
||||
};
|
||||
|
||||
export const useSetAgent = (showMessage: boolean = true) => {
|
||||
export const useSetAgent = (
|
||||
showMessage: boolean = true,
|
||||
skipInvalidation: boolean = false,
|
||||
) => {
|
||||
const { id } = useParams();
|
||||
const queryClient = useQueryClient();
|
||||
const {
|
||||
@@ -483,7 +486,7 @@ export const useSetAgent = (showMessage: boolean = true) => {
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: [AgentApiAction.FetchAgentListByPage],
|
||||
});
|
||||
if (agentId) {
|
||||
if (agentId && !skipInvalidation) {
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: [AgentApiAction.FetchAgentDetail, agentId],
|
||||
});
|
||||
|
||||
@@ -14,9 +14,12 @@ import { useParams } from 'react-router';
|
||||
import useGraphStore from '../store';
|
||||
import { useBuildDslData } from './use-build-dsl';
|
||||
|
||||
export const useSaveGraph = (showMessage: boolean = true) => {
|
||||
export const useSaveGraph = (
|
||||
showMessage: boolean = true,
|
||||
skipInvalidation: boolean = false,
|
||||
) => {
|
||||
const { data } = useFetchAgent();
|
||||
const { setAgent, loading } = useSetAgent(showMessage);
|
||||
const { setAgent, loading } = useSetAgent(showMessage, skipInvalidation);
|
||||
const { id } = useParams();
|
||||
const { buildDslData } = useBuildDslData();
|
||||
|
||||
@@ -72,7 +75,7 @@ export const useWatchAgentChange = (chatDrawerVisible: boolean) => {
|
||||
const [time, setTime] = useState<string>();
|
||||
const nodes = useGraphStore((state) => state.nodes);
|
||||
const edges = useGraphStore((state) => state.edges);
|
||||
const { saveGraph } = useSaveGraph(false);
|
||||
const { saveGraph } = useSaveGraph(false, true);
|
||||
const { data: flowDetail } = useFetchAgent();
|
||||
|
||||
const setSaveTime = useCallback((updateTime: number) => {
|
||||
@@ -86,7 +89,7 @@ export const useWatchAgentChange = (chatDrawerVisible: boolean) => {
|
||||
const saveAgent = useCallback(async () => {
|
||||
if (!chatDrawerVisible) {
|
||||
const ret = await saveGraph();
|
||||
setSaveTime(ret.data.update_time);
|
||||
setSaveTime(ret.data.update_time ?? Date.now());
|
||||
}
|
||||
}, [chatDrawerVisible, saveGraph, setSaveTime]);
|
||||
|
||||
|
||||
@@ -94,6 +94,7 @@ export function WikiLeftPanel({
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon-sm"
|
||||
className="ml-auto"
|
||||
disabled={loading}
|
||||
data-testid="wiki-clear-trigger"
|
||||
>
|
||||
|
||||
Reference in New Issue
Block a user