Skip to content

Commit

Permalink
removal of useEffect
Browse files Browse the repository at this point in the history
  • Loading branch information
prakriti-solankey authored Dec 24, 2024
1 parent fd30d8d commit 1331810
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 25 deletions.
18 changes: 16 additions & 2 deletions frontend/src/components/Content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ const Content: React.FC<ContentProps> = ({
alertType: 'neutral',
alertMessage: '',
});
const { setClearHistoryData } = useMessageContext();
const { setMessages } = useMessageContext();
const {
filesData,
setFilesData,
Expand Down Expand Up @@ -536,14 +536,28 @@ const Content: React.FC<ContentProps> = ({

const disconnect = () => {
queue.clear();
const date = new Date();
setProcessedCount(0);
setConnectionStatus(false);
localStorage.removeItem('password');
localStorage.removeItem('selectedModel');
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']]);
};

Expand Down
25 changes: 2 additions & 23 deletions frontend/src/components/Layout/SideNav.tsx
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -43,7 +43,7 @@ const SideNav: React.FC<SideNavProps> = ({
}) => {
const [isChatModalOpen, setIsChatModalOpen] = useState(false);
const [isFullScreen, setIsFullScreen] = useState(false);
const { setMessages, isDeleteChatLoading, setClearHistoryData } = useMessageContext();
const { setMessages, isDeleteChatLoading } = useMessageContext();
const [showChatMode, setshowChatMode] = useState<boolean>(false);
const largedesktops = useMediaQuery(`(min-width:1440px )`);
const { connectionStatus, isReadOnlyUser } = useCredentials();
Expand Down Expand Up @@ -77,27 +77,6 @@ const SideNav: React.FC<SideNavProps> = ({
}
};

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 (
<div style={{ height: 'calc(100vh - 58px)', minHeight: '200px', display: 'flex' }}>
<SideNavigation hasIconMenu={true} isExpanded={false} position={position}>
Expand Down

0 comments on commit 1331810

Please sign in to comment.