mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2026-01-02 02:09:03 +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(() => {
|
useEffect(() => {
|
||||||
// activeTopic not in assistant.topics
|
// 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])
|
setActiveTopic(assistant.topics[0])
|
||||||
}
|
}
|
||||||
}, [activeTopic?.id, assistant])
|
}, [activeTopic?.id, assistant])
|
||||||
|
|||||||
@ -29,6 +29,7 @@ const HomePage: FC = () => {
|
|||||||
|
|
||||||
const setActiveAssistant = useCallback(
|
const setActiveAssistant = useCallback(
|
||||||
(newAssistant: Assistant) => {
|
(newAssistant: Assistant) => {
|
||||||
|
if (newAssistant.id === activeAssistant.id) return
|
||||||
startTransition(() => {
|
startTransition(() => {
|
||||||
_setActiveAssistant(newAssistant)
|
_setActiveAssistant(newAssistant)
|
||||||
// 同步更新 active topic,避免不必要的重新渲染
|
// 同步更新 active topic,避免不必要的重新渲染
|
||||||
@ -36,7 +37,7 @@ const HomePage: FC = () => {
|
|||||||
_setActiveTopic((prev) => (newTopic?.id === prev.id ? prev : newTopic))
|
_setActiveTopic((prev) => (newTopic?.id === prev.id ? prev : newTopic))
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
[_setActiveTopic]
|
[_setActiveTopic, activeAssistant]
|
||||||
)
|
)
|
||||||
|
|
||||||
const setActiveTopic = useCallback(
|
const setActiveTopic = useCallback(
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user