prevent selectChatIndex -1 error
This commit is contained in:
@@ -129,7 +129,7 @@ export function App() {
|
||||
);
|
||||
setSelectedChatIndex(0);
|
||||
} else {
|
||||
setSelectedChatIndex(selectedChatIndex - 1);
|
||||
setSelectedChatIndex(Math.max(selectedChatIndex - 1, 0));
|
||||
}
|
||||
setAllChatStore([...allChatStore]);
|
||||
}}
|
||||
|
||||
@@ -8,6 +8,8 @@ export default function ChatBOX(props: {
|
||||
setChatStore: (cs: ChatStore) => void;
|
||||
}) {
|
||||
const { chatStore, setChatStore } = props;
|
||||
// prevent error
|
||||
if (chatStore === undefined) return <div></div>;
|
||||
const [inputMsg, setInputMsg] = useState("");
|
||||
const [showGenerating, setShowGenerating] = useState(false);
|
||||
const [generatingMessage, setGeneratingMessage] = useState("");
|
||||
|
||||
Reference in New Issue
Block a user