Fixed the redux state changes

This commit is contained in:
Niharika Goulikar
2024-10-18 09:55:33 +00:00
parent 1757ce23af
commit 5854202f22
2 changed files with 11 additions and 7 deletions

View File

@@ -96,6 +96,9 @@ export default function Navigation({ navOpen, setNavOpen }: NavigationProps) {
if (!conversations) { if (!conversations) {
fetchConversations(); fetchConversations();
} }
if (queries.length === 0) {
resetConversation();
}
}, [conversations, dispatch]); }, [conversations, dispatch]);
async function fetchConversations() { async function fetchConversations() {
@@ -168,9 +171,8 @@ export default function Navigation({ navOpen, setNavOpen }: NavigationProps) {
); );
}; };
const newChat = () => { const newChat = () => {
if (conversations && conversations?.length > 0) { if (queries && queries?.length > 0) {
resetConversation(); resetConversation();
navigate('/');
} }
}; };
async function updateConversationName(updatedConversation: { async function updateConversationName(updatedConversation: {

View File

@@ -49,6 +49,9 @@ export default function Conversation() {
}; };
useEffect(() => { useEffect(() => {
!eventInterrupt && scrollIntoView(); !eventInterrupt && scrollIntoView();
if (queries.length == 0) {
resetConversation();
}
}, [queries.length, queries[queries.length - 1]]); }, [queries.length, queries[queries.length - 1]]);
useEffect(() => { useEffect(() => {
@@ -132,8 +135,7 @@ export default function Conversation() {
); );
}; };
const newChat = () => { const newChat = () => {
resetConversation(); if (queries && queries.length > 0) resetConversation();
navigate('/');
}; };
const prepResponseView = (query: Query, index: number) => { const prepResponseView = (query: Query, index: number) => {
@@ -213,11 +215,11 @@ export default function Conversation() {
}, []); }, []);
return ( return (
<div className="flex flex-col gap-1 h-full justify-end "> <div className="flex flex-col gap-1 h-full justify-end ">
{conversationId && ( {conversationId && queries.length > 0 && (
<div className="absolute top-4 right-20 z-20 "> <div className="absolute top-4 right-20 z-20 ">
{' '} {' '}
<div className="flex items-center gap-4 "> <div className="flex items-center gap-4 ">
{isMobile && ( {isMobile && queries.length > 0 && (
<button <button
title="Open New Chat" title="Open New Chat"
onClick={() => { onClick={() => {
@@ -227,7 +229,7 @@ export default function Conversation() {
> >
<img <img
className=" h-5 w-5 filter dark:invert " className=" h-5 w-5 filter dark:invert "
alt="share" alt="NewChat"
src={newChatIcon} src={newChatIcon}
/> />
</button> </button>