mirror of
https://github.com/wassname/chatGPTBox.git
synced 2026-08-02 12:30:35 +08:00
patch: fakePort stop
This commit is contained in:
@@ -260,6 +260,7 @@ function ConversationCard(props) {
|
||||
const lastRecord = session.conversationRecords[session.conversationRecords.length - 1]
|
||||
if (
|
||||
conversationItemData[conversationItemData.length - 1].done &&
|
||||
conversationItemData.length > 1 &&
|
||||
lastRecord.question === conversationItemData[conversationItemData.length - 2].content
|
||||
) {
|
||||
session.conversationRecords.pop()
|
||||
@@ -484,15 +485,13 @@ function ConversationCard(props) {
|
||||
key={idx}
|
||||
type={data.type}
|
||||
session={session}
|
||||
done={data.done}
|
||||
port={port}
|
||||
onRetry={idx === conversationItemData.length - 1 ? getRetryFn(session) : null}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
<InputBox
|
||||
enabled={isReady}
|
||||
port={port}
|
||||
postMessage={postMessage}
|
||||
reverseResizeDir={props.pageMode}
|
||||
onSubmit={async (question) => {
|
||||
const newQuestion = new ConversationItemData('question', question)
|
||||
|
||||
@@ -9,7 +9,7 @@ import { isUsingCustomModel } from '../../config/index.mjs'
|
||||
import { useConfig } from '../../hooks/use-config.mjs'
|
||||
|
||||
// eslint-disable-next-line
|
||||
export function ConversationItem({ type, content, session, done, port, onRetry }) {
|
||||
export function ConversationItem({ type, content, session, onRetry }) {
|
||||
const { t } = useTranslation()
|
||||
const [collapsed, setCollapsed] = useState(false)
|
||||
const config = useConfig()
|
||||
@@ -129,8 +129,6 @@ ConversationItem.propTypes = {
|
||||
type: PropTypes.oneOf(['question', 'answer', 'error']).isRequired,
|
||||
content: PropTypes.string.isRequired,
|
||||
session: PropTypes.object.isRequired,
|
||||
done: PropTypes.bool.isRequired,
|
||||
port: PropTypes.object.isRequired,
|
||||
onRetry: PropTypes.func,
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import { isFirefox, isMobile, isSafari, updateRefHeight } from '../../utils'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { getUserConfig } from '../../config/index.mjs'
|
||||
|
||||
export function InputBox({ onSubmit, enabled, port, reverseResizeDir }) {
|
||||
export function InputBox({ onSubmit, enabled, postMessage, reverseResizeDir }) {
|
||||
const { t } = useTranslation()
|
||||
const [value, setValue] = useState('')
|
||||
const reverseDivRef = useRef(null)
|
||||
@@ -62,7 +62,7 @@ export function InputBox({ onSubmit, enabled, port, reverseResizeDir }) {
|
||||
onSubmit(value)
|
||||
setValue('')
|
||||
} else {
|
||||
port.postMessage({ stop: true })
|
||||
postMessage({ stop: true })
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -117,7 +117,7 @@ InputBox.propTypes = {
|
||||
onSubmit: PropTypes.func.isRequired,
|
||||
enabled: PropTypes.bool.isRequired,
|
||||
reverseResizeDir: PropTypes.bool,
|
||||
port: PropTypes.object.isRequired,
|
||||
postMessage: PropTypes.func.isRequired,
|
||||
}
|
||||
|
||||
export default InputBox
|
||||
|
||||
Reference in New Issue
Block a user