mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2025-12-26 03:31:24 +08:00
hotfix: error on deleting assistant (#8190)
fix: error on deleting assistant
This commit is contained in:
parent
27c39415c2
commit
df218ee6c8
@ -34,7 +34,7 @@ export function useActiveTopic(assistantId: string, topic?: Topic) {
|
||||
|
||||
useEffect(() => {
|
||||
// activeTopic not in assistant.topics
|
||||
if (assistant && !find(assistant.topics, { id: activeTopic?.id })) {
|
||||
if (assistant && assistant.topics.length > 0 && !find(assistant.topics, { id: activeTopic?.id })) {
|
||||
setActiveTopic(assistant.topics[0])
|
||||
}
|
||||
}, [activeTopic?.id, assistant])
|
||||
|
||||
@ -29,6 +29,7 @@ const HomePage: FC = () => {
|
||||
|
||||
const setActiveAssistant = useCallback(
|
||||
(newAssistant: Assistant) => {
|
||||
if (newAssistant.id === activeAssistant.id) return
|
||||
startTransition(() => {
|
||||
_setActiveAssistant(newAssistant)
|
||||
// 同步更新 active topic,避免不必要的重新渲染
|
||||
@ -36,7 +37,7 @@ const HomePage: FC = () => {
|
||||
_setActiveTopic((prev) => (newTopic?.id === prev.id ? prev : newTopic))
|
||||
})
|
||||
},
|
||||
[_setActiveTopic]
|
||||
[_setActiveTopic, activeAssistant]
|
||||
)
|
||||
|
||||
const setActiveTopic = useCallback(
|
||||
|
||||
Loading…
Reference in New Issue
Block a user