From 2e3685c7e0c375d562f28d61b4e19d96b2d09839 Mon Sep 17 00:00:00 2001 From: kangfenmao Date: Sat, 15 Mar 2025 18:47:02 +0800 Subject: [PATCH] feat: emit send message event in Inputbar and clean up messages slice - Added event emission for sending messages in the Inputbar component to enhance message handling. - Removed redundant event emission from the messages slice to streamline the sendMessage function. --- src/renderer/src/pages/home/Inputbar/Inputbar.tsx | 2 ++ src/renderer/src/store/messages.ts | 3 --- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/renderer/src/pages/home/Inputbar/Inputbar.tsx b/src/renderer/src/pages/home/Inputbar/Inputbar.tsx index 1977abdb2e..605ef77572 100644 --- a/src/renderer/src/pages/home/Inputbar/Inputbar.tsx +++ b/src/renderer/src/pages/home/Inputbar/Inputbar.tsx @@ -146,6 +146,8 @@ const Inputbar: FC = ({ assistant: _assistant, setActiveTopic, topic }) = return } + EventEmitter.emit(EVENT_NAMES.SEND_MESSAGE) + try { // Dispatch the sendMessage action with all options const uploadedFiles = await FileManager.uploadFiles(files) diff --git a/src/renderer/src/store/messages.ts b/src/renderer/src/store/messages.ts index 1763ad2945..a83be56440 100644 --- a/src/renderer/src/store/messages.ts +++ b/src/renderer/src/store/messages.ts @@ -3,7 +3,6 @@ import db from '@renderer/databases' import { autoRenameTopic, TopicManager } from '@renderer/hooks/useTopic' import i18n from '@renderer/i18n' import { fetchChatCompletion } from '@renderer/services/ApiService' -import { EVENT_NAMES, EventEmitter } from '@renderer/services/EventService' import { getAssistantMessage, resetAssistantMessage } from '@renderer/services/MessagesService' import type { AppDispatch, RootState } from '@renderer/store' import type { Assistant, Message, Topic } from '@renderer/types' @@ -284,8 +283,6 @@ export const sendMessage = dispatch(clearTopicMessages(topic.id)) } - EventEmitter.emit(EVENT_NAMES.SEND_MESSAGE) - // 处理助手消息 let assistantMessages: Message[] = [] if (!isEmpty(options?.resendAssistantMessage)) {