Skip to content

Commit

Permalink
fix: start polling when knowledge source starts syncing
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanhopperlowe committed Dec 20, 2024
1 parent ffdbd37 commit d82bec7
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions ui/admin/app/hooks/knowledge/useKnowledgeSourceFiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
KnowledgeFile,
KnowledgeFileState,
KnowledgeSource,
KnowledgeSourceStatus,
} from "~/lib/model/knowledge";
import { KnowledgeService } from "~/lib/service/api/knowledgeService";
import { handlePromise } from "~/lib/service/async";
Expand All @@ -15,6 +16,14 @@ export function useKnowledgeSourceFiles(
) {
const [blockPollingFiles, setBlockPollingFiles] = useState(true);

const startPolling = () => {
if (blockPollingFiles) setBlockPollingFiles(false);
};

if (knowledgeSource.state === KnowledgeSourceStatus.Syncing) {
startPolling();
}

const {
data: files,
mutate: mutateFiles,
Expand Down Expand Up @@ -93,6 +102,7 @@ export function useKnowledgeSourceFiles(
reingestFile,
approveFile,
mutateFiles,
startPollingFiles: startPolling,
...rest,
};
}

0 comments on commit d82bec7

Please sign in to comment.