fix(chat): update chats list when creating a new chat

This commit is contained in:
iMADi-ARCH 2023-06-11 17:54:00 +05:30
parent d276126d01
commit 2fa9598fb4

View File

@ -108,11 +108,11 @@ export default function useChats() {
};
if (!chatId) {
// Creating a new chat
// setAllChats((chats) => {
// console.log({ chats });
// return [...chats, newChat];
// });
console.log("---- Creating a new chat ----");
setAllChats((chats) => {
console.log({ chats });
return [...chats, newChat];
});
setChat(newChat);
router.push(`/chat/${response.data.chatId}`);
}
@ -139,7 +139,7 @@ export default function useChats() {
const resetChat = async () => {
setChat(null);
}
};
useEffect(() => {
fetchAllChats();