Commit 47bcf52a authored by Joel's avatar Joel

fix: not clear more like this

parent a82d6485
'use client'
import type { FC } from 'react'
import React, { useState } from 'react'
import React, { useEffect, useState } from 'react'
import { useTranslation } from 'react-i18next'
import cn from 'classnames'
import copy from 'copy-to-clipboard'
......@@ -29,6 +29,7 @@ export type IGenerationItemProps = {
isInstalledApp: boolean
installedAppId?: string
taskId?: string
controlClearMoreLikeThis?: number
}
export const SimpleBtn = ({ className, onClick, children }: {
......@@ -84,6 +85,7 @@ const GenerationItem: FC<IGenerationItemProps> = ({
isInstalledApp,
installedAppId,
taskId,
controlClearMoreLikeThis,
}) => {
const { t } = useTranslation()
const isTop = depth === 1
......@@ -115,6 +117,7 @@ const GenerationItem: FC<IGenerationItemProps> = ({
isMobile,
isInstalledApp,
installedAppId,
controlClearMoreLikeThis,
}
const handleMoreLikeThis = async () => {
......@@ -141,6 +144,14 @@ const GenerationItem: FC<IGenerationItemProps> = ({
return res
})()
useEffect(() => {
if (controlClearMoreLikeThis) {
setChildMessageId(null)
setCompletionRes('')
}
}, [controlClearMoreLikeThis])
return (
<div className={cn(className, isTop ? 'rounded-xl border border-gray-200 bg-white' : 'rounded-br-xl !mt-0')}
style={isTop
......
......@@ -149,9 +149,13 @@ const Result: FC<IResultProps> = ({
},
}, isInstalledApp, installedAppInfo?.id)
}
const [controlClearMoreLikeThis, setControlClearMoreLikeThis] = useState(0)
useEffect(() => {
if (controlSend)
if (controlSend) {
handleSend()
setControlClearMoreLikeThis(Date.now())
}
}, [controlSend])
const renderTextGenerationRes = () => (
......@@ -169,6 +173,7 @@ const Result: FC<IResultProps> = ({
installedAppId={installedAppInfo?.id}
isLoading={isCallBatchAPI ? (!completionRes && isResponsing) : false}
taskId={isCallBatchAPI ? ((taskId as number) < 10 ? `0${taskId}` : `${taskId}`) : undefined}
controlClearMoreLikeThis={controlClearMoreLikeThis}
/>
)
......
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