diff --git a/frontend/src/components/Content.tsx b/frontend/src/components/Content.tsx index eb08c762..da502415 100644 --- a/frontend/src/components/Content.tsx +++ b/frontend/src/components/Content.tsx @@ -83,7 +83,7 @@ const Content: React.FC = ({ alertType: 'neutral', alertMessage: '', }); - const { setClearHistoryData } = useMessageContext(); + const { setMessages } = useMessageContext(); const { filesData, setFilesData, @@ -536,6 +536,7 @@ const Content: React.FC = ({ const disconnect = () => { queue.clear(); + const date = new Date(); setProcessedCount(0); setConnectionStatus(false); localStorage.removeItem('password'); @@ -543,7 +544,20 @@ const Content: React.FC = ({ setUserCredentials({ uri: '', password: '', userName: '', database: '' }); setSelectedNodes([]); setSelectedRels([]); - setClearHistoryData(true); + setMessages([ + { + datetime: `${date.toLocaleDateString()} ${date.toLocaleTimeString()}`, + id: 2, + modes: { + 'graph+vector+fulltext': { + message: + ' Welcome to the Neo4j Knowledge Graph Chat. You can ask questions related to documents which have been completely processed.', + }, + }, + user: 'chatbot', + currentMode: 'graph+vector+fulltext', + }, + ]); setchatModes([chatModeLables['graph+vector+fulltext']]); }; diff --git a/frontend/src/components/Layout/SideNav.tsx b/frontend/src/components/Layout/SideNav.tsx index 58ebf868..1cbc6626 100644 --- a/frontend/src/components/Layout/SideNav.tsx +++ b/frontend/src/components/Layout/SideNav.tsx @@ -1,4 +1,4 @@ -import React, { useEffect, useRef, useState } from 'react'; +import React, {useRef, useState } from 'react'; import { Dialog, SideNavigation, TextLink, Tooltip, useMediaQuery } from '@neo4j-ndl/react'; import { ArrowRightIconOutline, @@ -43,7 +43,7 @@ const SideNav: React.FC = ({ }) => { const [isChatModalOpen, setIsChatModalOpen] = useState(false); const [isFullScreen, setIsFullScreen] = useState(false); - const { setMessages, isDeleteChatLoading, setClearHistoryData } = useMessageContext(); + const { setMessages, isDeleteChatLoading } = useMessageContext(); const [showChatMode, setshowChatMode] = useState(false); const largedesktops = useMediaQuery(`(min-width:1440px )`); const { connectionStatus, isReadOnlyUser } = useCredentials(); @@ -77,27 +77,6 @@ const SideNav: React.FC = ({ } }; - useEffect(() => { - if (clearHistoryData) { - const currentDateTime = new Date(); - setMessages([ - { - datetime: `${currentDateTime.toLocaleDateString()} ${currentDateTime.toLocaleTimeString()}`, - id: 2, - modes: { - 'graph+vector+fulltext': { - message: - 'Welcome to the Neo4j Knowledge Graph Chat. You can ask questions related to documents which have been completely processed.', - }, - }, - user: 'chatbot', - currentMode: 'graph+vector+fulltext', - }, - ]); - setClearHistoryData(false); - } - }, [clearHistoryData, setMessages]); - return (