mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2025-12-19 14:41:24 +08:00
Merge 499ad5fabf into a6ba5d34e0
This commit is contained in:
commit
b4e48d959d
@ -62,7 +62,7 @@ const Messages: React.FC<MessagesProps> = ({ assistant, topic, setActiveTopic, o
|
|||||||
const [isLoadingMore, setIsLoadingMore] = useState(false)
|
const [isLoadingMore, setIsLoadingMore] = useState(false)
|
||||||
const [isProcessingContext, setIsProcessingContext] = useState(false)
|
const [isProcessingContext, setIsProcessingContext] = useState(false)
|
||||||
|
|
||||||
const { addTopic } = useAssistant(assistant.id)
|
const { addTopic, updateTopic, assistant: currentAssistant } = useAssistant(assistant.id)
|
||||||
const { showPrompt, messageNavigation } = useSettings()
|
const { showPrompt, messageNavigation } = useSettings()
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
const dispatch = useAppDispatch()
|
const dispatch = useAppDispatch()
|
||||||
@ -106,15 +106,28 @@ const Messages: React.FC<MessagesProps> = ({ assistant, topic, setActiveTopic, o
|
|||||||
|
|
||||||
const clearTopic = useCallback(
|
const clearTopic = useCallback(
|
||||||
async (data: Topic) => {
|
async (data: Topic) => {
|
||||||
if (data && data.id !== topic.id) {
|
const targetTopic = data && data.id !== topic.id ? data : topic
|
||||||
await clearTopicMessages(data.id)
|
const isCurrentTopic = targetTopic.id === topic.id
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
await clearTopicMessages()
|
if (!isCurrentTopic) {
|
||||||
setDisplayMessages([])
|
await clearTopicMessages(data.id)
|
||||||
|
} else {
|
||||||
|
await clearTopicMessages()
|
||||||
|
setDisplayMessages([])
|
||||||
|
}
|
||||||
|
if (currentAssistant?.topics.length === 1) {
|
||||||
|
const updatedTopic = {
|
||||||
|
...targetTopic,
|
||||||
|
name: t('chat.default.topic.name'),
|
||||||
|
isNameManuallyEdited: false
|
||||||
|
}
|
||||||
|
updateTopic(updatedTopic)
|
||||||
|
if (isCurrentTopic) {
|
||||||
|
setActiveTopic(updatedTopic)
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
[clearTopicMessages, topic.id]
|
[clearTopicMessages, topic, currentAssistant?.topics.length, updateTopic, setActiveTopic, t]
|
||||||
)
|
)
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user