From 7b2a5317c2f693a9a93b9e189a5151fafa652bbb Mon Sep 17 00:00:00 2001 From: Ryan Hopper-Lowe <46546486+ryanhopperlowe@users.noreply.github.com> Date: Mon, 2 Dec 2024 16:57:05 -0600 Subject: [PATCH] chore: fix linter warning related to useEffect (#729) --- .../app/components/knowledge/KnowledgeSourceDetail.tsx | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/ui/admin/app/components/knowledge/KnowledgeSourceDetail.tsx b/ui/admin/app/components/knowledge/KnowledgeSourceDetail.tsx index 4f302b27..a4dc4be6 100644 --- a/ui/admin/app/components/knowledge/KnowledgeSourceDetail.tsx +++ b/ui/admin/app/components/knowledge/KnowledgeSourceDetail.tsx @@ -1,7 +1,7 @@ import cronstrue from "cronstrue"; import { EditIcon, Eye, InfoIcon, Trash } from "lucide-react"; import { FC, useCallback, useEffect, useMemo, useRef, useState } from "react"; -import useSWR, { SWRResponse } from "swr"; +import useSWR from "swr"; import { KnowledgeFile, @@ -85,7 +85,7 @@ const KnowledgeSourceDetail: FC = ({ } }, [syncSchedule]); - const getFiles: SWRResponse = useSWR( + const getFiles = useSWR( KnowledgeService.getFilesForKnowledgeSource.key( agentId, knowledgeSource.id @@ -145,6 +145,7 @@ const KnowledgeSourceDetail: FC = ({ scrollPosition.current = tableContainerRef?.current?.scrollTop ?? 0; }; + const refreshFiles = getFiles.mutate; useEffect(() => { if ( knowledgeSource.state === KnowledgeSourceStatus.Syncing || @@ -154,9 +155,9 @@ const KnowledgeSourceDetail: FC = ({ } if (knowledgeSource.state === KnowledgeSourceStatus.Synced) { - getFiles.mutate(); + refreshFiles(); } - }, [knowledgeSource]); + }, [knowledgeSource, refreshFiles]); const onSourceUpdate = async (syncSchedule: string) => { const updatedSource = await KnowledgeService.updateKnowledgeSource(