diff --git a/src/app.tsx b/src/app.tsx index d436bda..2ab83fd 100644 --- a/src/app.tsx +++ b/src/app.tsx @@ -129,7 +129,7 @@ export function App() { ); setSelectedChatIndex(0); } else { - setSelectedChatIndex(selectedChatIndex - 1); + setSelectedChatIndex(Math.max(selectedChatIndex - 1, 0)); } setAllChatStore([...allChatStore]); }} diff --git a/src/chatbox.tsx b/src/chatbox.tsx index d3efda7..582cd0c 100644 --- a/src/chatbox.tsx +++ b/src/chatbox.tsx @@ -8,6 +8,8 @@ export default function ChatBOX(props: { setChatStore: (cs: ChatStore) => void; }) { const { chatStore, setChatStore } = props; + // prevent error + if (chatStore === undefined) return
; const [inputMsg, setInputMsg] = useState(""); const [showGenerating, setShowGenerating] = useState(false); const [generatingMessage, setGeneratingMessage] = useState("");