Commit 2c03e162 authored by Joel's avatar Joel

fix: to new conversation bug

parent d0684a09
......@@ -509,11 +509,13 @@ const Chat: FC<IChatProps> = ({
})
}
const hasChatStart = chatList.some(item => !item.isAnswer)
return (
<div className={cn('px-3.5', 'h-full')}>
{chatList.length === 0 && (configElem || null)}
{!hasChatStart && (configElem || null)}
{/* 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) => {
if (item.isAnswer) {
const isLast = item.id === chatList[chatList.length - 1].id
......
......@@ -155,15 +155,6 @@ const Main: FC<IMainProps> = () => {
const [speechToTextConfig, setSpeechToTextConfig] = useState<SuggestedQuestionsAfterAnswerConfig | null>(null)
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 conversationIntroduction = currConversationInfo?.introduction || ''
......@@ -175,6 +166,7 @@ const Main: FC<IMainProps> = () => {
// update inputs of current conversation
let notSyncToStateIntroduction = ''
let notSyncToStateInputs: Record<string, any> | undefined | null = {}
// debugger
if (!isNewConversation) {
const item = allConversationList.find(item => item.id === currConversationId)
notSyncToStateInputs = item?.inputs || {}
......@@ -213,7 +205,7 @@ const Main: FC<IMainProps> = () => {
})
}
if (isNewConversation && isChatStarted)
if (isNewConversation)
setChatList(generateNewChatListWithOpenstatement())
setControlFocus(Date.now())
......@@ -459,7 +451,6 @@ const Main: FC<IMainProps> = () => {
}
setConversationIdChangeBecauseOfNew(false)
resetNewConversationInputs()
setChatNotStarted()
setCurrConversationId(tempNewConversationId, APP_ID, true)
if (suggestedQuestionsAfterAnswerConfig?.enabled && !getHasStopResponded()) {
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