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

View File

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