From 60e87e8a22b7229843d3dda39229fc41954b2bcc Mon Sep 17 00:00:00 2001 From: kangfenmao Date: Thu, 19 Sep 2024 23:01:21 +0800 Subject: [PATCH] fix: Disable topic switching and movement during rendering. - Added functionality to disable topic switching and movement when rendering is in progress. --- src/renderer/src/pages/home/Topics.tsx | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/renderer/src/pages/home/Topics.tsx b/src/renderer/src/pages/home/Topics.tsx index 167c0e4c..ff309381 100644 --- a/src/renderer/src/pages/home/Topics.tsx +++ b/src/renderer/src/pages/home/Topics.tsx @@ -26,28 +26,36 @@ const Topics: FC = ({ assistant: _assistant, activeTopic, setActiveTopic const onDeleteTopic = useCallback( (topic: Topic) => { + if (generating) { + window.message.warning({ content: t('message.switch.disabled'), key: 'generating' }) + return + } if (assistant.topics.length > 1) { const index = findIndex(assistant.topics, (t) => t.id === topic.id) setActiveTopic(assistant.topics[index + 1 === assistant.topics.length ? 0 : index + 1]) removeTopic(topic) } }, - [assistant.topics, removeTopic, setActiveTopic] + [assistant.topics, generating, removeTopic, setActiveTopic, t] ) const onMoveTopic = useCallback( (topic: Topic, toAssistant: Assistant) => { + if (generating) { + window.message.warning({ content: t('message.switch.disabled'), key: 'generating' }) + return + } const index = findIndex(assistant.topics, (t) => t.id === topic.id) setActiveTopic(assistant.topics[index + 1 === assistant.topics.length ? 0 : index + 1]) moveTopic(topic, toAssistant) }, - [assistant.topics, moveTopic, setActiveTopic] + [assistant.topics, generating, moveTopic, setActiveTopic, t] ) const onSwitchTopic = useCallback( (topic: Topic) => { if (generating) { - window.message.warning({ content: t('message.switch.disabled'), key: 'switch-assistant' }) + window.message.warning({ content: t('message.switch.disabled'), key: 'generating' }) return } setActiveTopic(topic)