fix deletion bug

This commit is contained in:
Mckay Wrigley 2023-03-15 08:32:21 -06:00
parent 742efea50d
commit c40f755cac
3 changed files with 5 additions and 2 deletions

View File

@ -6,7 +6,7 @@ It aims to mimic ChatGPT's interface and functionality.
All conversations are stored locally on your device. All conversations are stored locally on your device.
See a [demo]() See a [demo]().
![Chatbot UI Pro](./public/screenshot.png) ![Chatbot UI Pro](./public/screenshot.png)

View File

@ -11,6 +11,7 @@ interface Props {
} }
export const Conversations: FC<Props> = ({ loading, conversations, selectedConversation, onSelectConversation, onDeleteConversation }) => { export const Conversations: FC<Props> = ({ loading, conversations, selectedConversation, onSelectConversation, onDeleteConversation }) => {
console.log(conversations);
return ( return (
<div className="flex flex-col space-y-2"> <div className="flex flex-col space-y-2">
{conversations.map((conversation, index) => ( {conversations.map((conversation, index) => (

View File

@ -119,8 +119,10 @@ export default function Home() {
}; };
const handleNewConversation = () => { const handleNewConversation = () => {
const lastConversation = conversations[conversations.length - 1];
const newConversation: Conversation = { const newConversation: Conversation = {
id: conversations.length + 1, id: lastConversation ? lastConversation.id + 1 : 1,
name: "", name: "",
messages: [] messages: []
}; };