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:
parent
8faececa4c
commit
8c3ce1a787
@ -17,6 +17,8 @@ import {
|
|||||||
import type { Assistant, Message, Topic } from '@renderer/types'
|
import type { Assistant, Message, Topic } from '@renderer/types'
|
||||||
import { abortCompletion } from '@renderer/utils/abortController'
|
import { abortCompletion } from '@renderer/utils/abortController'
|
||||||
import { useCallback } from 'react'
|
import { useCallback } from 'react'
|
||||||
|
|
||||||
|
import { TopicManager } from './useTopic'
|
||||||
/**
|
/**
|
||||||
* 自定义Hook,提供消息操作相关的功能
|
* 自定义Hook,提供消息操作相关的功能
|
||||||
*
|
*
|
||||||
@ -126,7 +128,9 @@ export function useMessageOperations(topic: Topic) {
|
|||||||
*/
|
*/
|
||||||
const clearTopicMessagesAction = useCallback(
|
const clearTopicMessagesAction = useCallback(
|
||||||
async (_topicId?: string) => {
|
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]
|
[dispatch, topic.id]
|
||||||
)
|
)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user