fix naming bugs

This commit is contained in:
Mckay Wrigley 2023-03-18 06:49:20 -06:00
parent 9807ba4c42
commit 16513b20de
2 changed files with 10 additions and 12 deletions

View File

@ -19,7 +19,7 @@ interface Props {
export const Sidebar: FC<Props> = ({ loading, conversations, lightMode, selectedConversation, onNewConversation, onToggleLightMode, onSelectConversation, onDeleteConversation, onToggleSidebar, onRenameConversation }) => { export const Sidebar: FC<Props> = ({ loading, conversations, lightMode, selectedConversation, onNewConversation, onToggleLightMode, onSelectConversation, onDeleteConversation, onToggleSidebar, onRenameConversation }) => {
return ( return (
<div className="flex flex-col bg-[#202123] min-w-[260px]"> <div className="flex flex-col bg-[#202123] min-w-[260px] max-w-[260px]">
<div className="flex items-center h-[60px] pl-2"> <div className="flex items-center h-[60px] pl-2">
<button <button
className="flex items-center w-[200px] h-[40px] rounded-lg bg-[#202123] border border-neutral-600 text-sm hover:bg-neutral-700" className="flex items-center w-[200px] h-[40px] rounded-lg bg-[#202123] border border-neutral-600 text-sm hover:bg-neutral-700"

View File

@ -68,7 +68,6 @@ export default function Home() {
updatedConversation = { updatedConversation = {
...updatedConversation, ...updatedConversation,
name: message.content,
messages: updatedMessages messages: updatedMessages
}; };
@ -122,12 +121,14 @@ export default function Home() {
}; };
const handleRenameConversation = (conversation: Conversation, name: string) => { const handleRenameConversation = (conversation: Conversation, name: string) => {
const updatedConversations = conversations.map((c) => { const updatedConversation = {
if (c.id === conversation.id) { ...conversation,
return {
...c,
name name
}; };
const updatedConversations = conversations.map((c) => {
if (c.id === updatedConversation.id) {
return updatedConversation;
} }
return c; return c;
@ -136,11 +137,8 @@ export default function Home() {
setConversations(updatedConversations); setConversations(updatedConversations);
localStorage.setItem("conversationHistory", JSON.stringify(updatedConversations)); localStorage.setItem("conversationHistory", JSON.stringify(updatedConversations));
setSelectedConversation({ setSelectedConversation(updatedConversation);
...conversation, localStorage.setItem("selectedConversation", JSON.stringify(updatedConversation));
name
});
localStorage.setItem("selectedConversation", JSON.stringify(selectedConversation));
}; };
const handleNewConversation = () => { const handleNewConversation = () => {