feat: Enhance message clearing functionality in useMessageOperations

- Updated clearTopicMessagesAction to utilize TopicManager for clearing messages.
- Improved handling of topic IDs to ensure correct message clearing based on provided or default topic ID.
This commit is contained in:
kangfenmao 2025-03-14 18:00:41 +08:00
parent 8faececa4c
commit 8c3ce1a787

View File

@ -17,6 +17,8 @@ import {
import type { Assistant, Message, Topic } from '@renderer/types'
import { abortCompletion } from '@renderer/utils/abortController'
import { useCallback } from 'react'
import { TopicManager } from './useTopic'
/**
* Hook
*
@ -126,7 +128,9 @@ export function useMessageOperations(topic: Topic) {
*/
const clearTopicMessagesAction = useCallback(
async (_topicId?: string) => {
await dispatch(clearTopicMessages(_topicId || topic.id))
const topicId = _topicId || topic.id
await dispatch(clearTopicMessages(topicId))
await TopicManager.clearTopicMessages(topicId)
},
[dispatch, topic.id]
)