From 5ce0f6ac870d7ca5a0cd96e3b40e106bfee9406b Mon Sep 17 00:00:00 2001 From: Antoine Dewez <44063631+Zewed@users.noreply.github.com> Date: Tue, 23 Jul 2024 19:50:54 +0200 Subject: [PATCH] fix(frontend): remove current brain id when click on create brain (#2906) # Description Please include a summary of the changes and the related issue. Please also include relevant motivation and context. ## Checklist before requesting a review Please delete options that are not relevant. - [ ] My code follows the style guidelines of this project - [ ] I have performed a self-review of my code - [ ] I have commented hard-to-understand areas - [ ] I have ideally added tests that prove my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes - [ ] Any dependent changes have been merged ## Screenshots (if appropriate): --- frontend/lib/components/AddBrainModal/AddBrainModal.tsx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/frontend/lib/components/AddBrainModal/AddBrainModal.tsx b/frontend/lib/components/AddBrainModal/AddBrainModal.tsx index 7659829bc..47dd04add 100644 --- a/frontend/lib/components/AddBrainModal/AddBrainModal.tsx +++ b/frontend/lib/components/AddBrainModal/AddBrainModal.tsx @@ -5,6 +5,7 @@ import { useTranslation } from "react-i18next"; import { useFromConnectionsContext } from "@/app/chat/[chatId]/components/ActionsBar/components/KnowledgeToFeed/components/FromConnections/FromConnectionsProvider/hooks/useFromConnectionContext"; import { Modal } from "@/lib/components/ui/Modal/Modal"; import { addBrainDefaultValues } from "@/lib/config/defaultBrainConfig"; +import { useBrainContext } from "@/lib/context/BrainProvider/hooks/useBrainContext"; import { useKnowledgeToFeedContext } from "@/lib/context/KnowledgeToFeedProvider/hooks/useKnowledgeToFeedContext"; import { useUserData } from "@/lib/hooks/useUserData"; @@ -21,6 +22,7 @@ export const AddBrainModal = (): JSX.Element => { const { t } = useTranslation(["translation", "brain", "config"]); const { userIdentityData } = useUserData(); const { currentStep, steps } = useBrainCreationSteps(); + const { setCurrentBrainId } = useBrainContext(); const { isBrainCreationModalOpened, setIsBrainCreationModalOpened, @@ -48,6 +50,9 @@ export const AddBrainModal = (): JSX.Element => { setOpenedConnections([]); methods.reset(defaultValues); removeAllKnowledgeToFeed(); + if (isBrainCreationModalOpened) { + setCurrentBrainId(null); + } }, [isBrainCreationModalOpened]); return (