From 8c3ce1a787f62ce54e6ed52c00c9a15a7a544129 Mon Sep 17 00:00:00 2001 From: kangfenmao Date: Fri, 14 Mar 2025 18:00:41 +0800 Subject: [PATCH] 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. --- src/renderer/src/hooks/useMessageOperations.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/renderer/src/hooks/useMessageOperations.ts b/src/renderer/src/hooks/useMessageOperations.ts index 7c6b2142..f62b8654 100644 --- a/src/renderer/src/hooks/useMessageOperations.ts +++ b/src/renderer/src/hooks/useMessageOperations.ts @@ -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] )