Commit 47bcf52a authored by Joel's avatar Joel

fix: not clear more like this

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