Commit 2c03e162 authored by Joel's avatar Joel

fix: to new conversation bug

parent d0684a09
...@@ -509,11 +509,13 @@ const Chat: FC<IChatProps> = ({ ...@@ -509,11 +509,13 @@ const Chat: FC<IChatProps> = ({
}) })
} }
const hasChatStart = chatList.some(item => !item.isAnswer)
return ( return (
<div className={cn('px-3.5', 'h-full')}> <div className={cn('px-3.5', 'h-full')}>
{chatList.length === 0 && (configElem || null)} {!hasChatStart && (configElem || null)}
{/* Chat List */} {/* Chat List */}
<div className={cn((chatList.length === 0 && configElem) ? 'h-0' : 'h-full', 'space-y-[30px]')}> <div className={cn((!hasChatStart && configElem) ? 'h-0' : 'h-full', 'space-y-[30px]')}>
{chatList.map((item) => { {chatList.map((item) => {
if (item.isAnswer) { if (item.isAnswer) {
const isLast = item.id === chatList[chatList.length - 1].id const isLast = item.id === chatList[chatList.length - 1].id
......
...@@ -155,15 +155,6 @@ const Main: FC<IMainProps> = () => { ...@@ -155,15 +155,6 @@ const Main: FC<IMainProps> = () => {
const [speechToTextConfig, setSpeechToTextConfig] = useState<SuggestedQuestionsAfterAnswerConfig | null>(null) const [speechToTextConfig, setSpeechToTextConfig] = useState<SuggestedQuestionsAfterAnswerConfig | null>(null)
const [conversationIdChangeBecauseOfNew, setConversationIdChangeBecauseOfNew, getConversationIdChangeBecauseOfNew] = useGetState(false) const [conversationIdChangeBecauseOfNew, setConversationIdChangeBecauseOfNew, getConversationIdChangeBecauseOfNew] = useGetState(false)
const [isChatStarted, { setTrue: setChatStarted, setFalse: setChatNotStarted }] = useBoolean(false)
const handleStartChat = (inputs: Record<string, any>) => {
createNewChat()
setConversationIdChangeBecauseOfNew(true)
setCurrInputs(inputs)
setChatStarted()
// parse variables in introduction
setChatList(generateNewChatListWithOpenstatement('', inputs))
}
const conversationName = currConversationInfo?.name || t('share.chat.newChatDefaultName') as string const conversationName = currConversationInfo?.name || t('share.chat.newChatDefaultName') as string
const conversationIntroduction = currConversationInfo?.introduction || '' const conversationIntroduction = currConversationInfo?.introduction || ''
...@@ -175,6 +166,7 @@ const Main: FC<IMainProps> = () => { ...@@ -175,6 +166,7 @@ const Main: FC<IMainProps> = () => {
// update inputs of current conversation // update inputs of current conversation
let notSyncToStateIntroduction = '' let notSyncToStateIntroduction = ''
let notSyncToStateInputs: Record<string, any> | undefined | null = {} let notSyncToStateInputs: Record<string, any> | undefined | null = {}
// debugger
if (!isNewConversation) { if (!isNewConversation) {
const item = allConversationList.find(item => item.id === currConversationId) const item = allConversationList.find(item => item.id === currConversationId)
notSyncToStateInputs = item?.inputs || {} notSyncToStateInputs = item?.inputs || {}
...@@ -213,7 +205,7 @@ const Main: FC<IMainProps> = () => { ...@@ -213,7 +205,7 @@ const Main: FC<IMainProps> = () => {
}) })
} }
if (isNewConversation && isChatStarted) if (isNewConversation)
setChatList(generateNewChatListWithOpenstatement()) setChatList(generateNewChatListWithOpenstatement())
setControlFocus(Date.now()) setControlFocus(Date.now())
...@@ -459,7 +451,6 @@ const Main: FC<IMainProps> = () => { ...@@ -459,7 +451,6 @@ const Main: FC<IMainProps> = () => {
} }
setConversationIdChangeBecauseOfNew(false) setConversationIdChangeBecauseOfNew(false)
resetNewConversationInputs() resetNewConversationInputs()
setChatNotStarted()
setCurrConversationId(tempNewConversationId, APP_ID, true) setCurrConversationId(tempNewConversationId, APP_ID, true)
if (suggestedQuestionsAfterAnswerConfig?.enabled && !getHasStopResponded()) { if (suggestedQuestionsAfterAnswerConfig?.enabled && !getHasStopResponded()) {
const { data }: any = await fetchSuggestedQuestions(responseItem.id) const { data }: any = await fetchSuggestedQuestions(responseItem.id)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment