mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-08-19 06:48:25 +08:00
Fix: Initiate a request to check for file changes two seconds after compilation completes. (#18440)
This commit is contained in:
@@ -14,6 +14,7 @@ import {
|
||||
useTraceRunData,
|
||||
} from '@/hooks/use-dataset-generate';
|
||||
import {
|
||||
ArtifactAlterationKeys,
|
||||
DatasetStructureKeys,
|
||||
useDeleteDatasetStructure,
|
||||
useFetchArtifactAlteration,
|
||||
@@ -71,7 +72,11 @@ export function DatasetStructureView({ kind }: DatasetStructureViewProps) {
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: DatasetStructureKeys.kind(knowledgeBaseId, kind),
|
||||
});
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: ArtifactAlterationKeys.detail(knowledgeBaseId, kind),
|
||||
});
|
||||
}, [queryClient, knowledgeBaseId, kind]);
|
||||
|
||||
useRunEndEffect(structureStatus, handleRunEnd);
|
||||
|
||||
const entityOptions = useMemo<SelectWithSearchFlagOptionType[]>(
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
import { GenerateStatus } from '@/constants/knowledge';
|
||||
import { useDebounceFn } from 'ahooks';
|
||||
import { useEffect, useRef } from 'react';
|
||||
|
||||
// Fires once when a compilation run leaves the Running state, no matter how it
|
||||
// ended: finished at 100% (Running -> Completed), paused (the task is unbound,
|
||||
// so the trace resets and Running -> Start), or failed. Views refresh their
|
||||
// data through this single path so pausing behaves exactly like completion.
|
||||
export function useRunEndEffect(
|
||||
status: GenerateStatus,
|
||||
onRunEnd: () => void,
|
||||
) {
|
||||
// Debounced to fire 1s after the run settles, so the refetch reads final state.
|
||||
export function useRunEndEffect(status: GenerateStatus, onRunEnd: () => void) {
|
||||
const prevStatusRef = useRef(status);
|
||||
const { run: scheduleRunEnd } = useDebounceFn(onRunEnd, { wait: 2000 });
|
||||
|
||||
useEffect(() => {
|
||||
const prevStatus = prevStatusRef.current;
|
||||
@@ -18,7 +18,7 @@ export function useRunEndEffect(
|
||||
prevStatus === GenerateStatus.Running &&
|
||||
status !== GenerateStatus.Running
|
||||
) {
|
||||
onRunEnd();
|
||||
scheduleRunEnd();
|
||||
}
|
||||
}, [status, onRunEnd]);
|
||||
}, [status, scheduleRunEnd]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user