Skip to content

Commit

Permalink
Fix: fix fe code to not make requests when validating cache (#720)
Browse files Browse the repository at this point in the history
Signed-off-by: Daishan Peng <[email protected]>
  • Loading branch information
StrongMonkey authored Dec 2, 2024
1 parent e149f0c commit 24cf54d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
4 changes: 2 additions & 2 deletions ui/admin/app/components/knowledge/AgentKnowledgePanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export default function AgentKnowledgePanel({
),
{
revalidateOnFocus: false,
refreshInterval: blockPollingLocalFiles ? undefined : 1000,
refreshInterval: blockPollingLocalFiles ? undefined : 5000,
}
);
const localFiles = useMemo(
Expand All @@ -110,7 +110,7 @@ export default function AgentKnowledgePanel({
({ agentId }) => KnowledgeService.getKnowledgeSourcesForAgent(agentId),
{
revalidateOnFocus: false,
refreshInterval: blockPollingSources ? undefined : 1000,
refreshInterval: blockPollingSources ? undefined : 5000,
}
);
const knowledgeSources = useMemo(
Expand Down
14 changes: 8 additions & 6 deletions ui/admin/app/components/knowledge/KnowledgeSourceDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ const KnowledgeSourceDetail: FC<KnowledgeSourceDetailProps> = ({
),
{
revalidateOnFocus: false,
refreshInterval: blockPollingFiles ? undefined : 1000,
refreshInterval: blockPollingFiles ? undefined : 5000,
}
);

Expand Down Expand Up @@ -156,7 +156,7 @@ const KnowledgeSourceDetail: FC<KnowledgeSourceDetailProps> = ({
if (knowledgeSource.state === KnowledgeSourceStatus.Synced) {
getFiles.mutate();
}
}, [knowledgeSource, getFiles]);
}, [knowledgeSource]);

const onSourceUpdate = async (syncSchedule: string) => {
const updatedSource = await KnowledgeService.updateKnowledgeSource(
Expand All @@ -176,8 +176,9 @@ const KnowledgeSourceDetail: FC<KnowledgeSourceDetailProps> = ({
file.id,
approved
);
getFiles.mutate((files) =>
files?.map((f) => (f.id === file.id ? updatedFile : f))
getFiles.mutate(
(files) => files?.map((f) => (f.id === file.id ? updatedFile : f)),
false
);
};

Expand All @@ -203,8 +204,9 @@ const KnowledgeSourceDetail: FC<KnowledgeSourceDetailProps> = ({
file.id,
knowledgeSource.id
);
getFiles.mutate((files) =>
files?.map((f) => (f.id === file.id ? updatedFile : f))
getFiles.mutate(
(files) => files?.map((f) => (f.id === file.id ? updatedFile : f)),
false
);
};

Expand Down

0 comments on commit 24cf54d

Please sign in to comment.