From dcea49d6add6ea2798bd2663fdd364e164b79b19 Mon Sep 17 00:00:00 2001 From: Jing Hua Date: Sun, 26 Mar 2023 10:40:50 +0800 Subject: [PATCH] disable changing chat during generation fixes #117, fixes #67 --- src/components/Menu/ChatHistoryList.tsx | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/components/Menu/ChatHistoryList.tsx b/src/components/Menu/ChatHistoryList.tsx index 862717c..fd3b05c 100644 --- a/src/components/Menu/ChatHistoryList.tsx +++ b/src/components/Menu/ChatHistoryList.tsx @@ -54,9 +54,9 @@ const ShowMoreButton = () => { const ChatHistoryClass = { normal: - 'flex py-3 px-3 items-center gap-3 relative rounded-md hover:bg-[#2A2B32] cursor-pointer break-all hover:pr-4 group', + 'flex py-3 px-3 items-center gap-3 relative rounded-md hover:bg-[#2A2B32] break-all hover:pr-4 group', active: - 'flex py-3 px-3 items-center gap-3 relative rounded-md cursor-pointer break-all pr-14 bg-gray-800 hover:bg-gray-800 group', + 'flex py-3 px-3 items-center gap-3 relative rounded-md break-all pr-14 bg-gray-800 hover:bg-gray-800 group', normalGradient: 'absolute inset-y-0 right-0 w-8 z-10 bg-gradient-to-l from-gray-900 group-hover:from-[#2A2B32]', activeGradient: @@ -69,6 +69,7 @@ const ChatHistory = React.memo( const setCurrentChatIndex = useStore((state) => state.setCurrentChatIndex); const setChats = useStore((state) => state.setChats); const active = useStore((state) => state.currentChatIndex === chatIndex); + const generating = useStore((state) => state.generating); const [isDelete, setIsDelete] = useState(false); const [isEdit, setIsEdit] = useState(false); @@ -107,9 +108,11 @@ const ChatHistory = React.memo( return ( { - setCurrentChatIndex(chatIndex); + className={`${ + active ? ChatHistoryClass.active : ChatHistoryClass.normal + } ${generating ? 'cursor-not-allowed' : 'cursor-pointer'}`} + onClick={() => { + if (!generating) setCurrentChatIndex(chatIndex); }} >