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):
This commit is contained in:
Antoine Dewez 2024-07-23 19:50:54 +02:00 committed by GitHub
parent 25178b2c2e
commit 5ce0f6ac87
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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 (