mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2025-12-25 19:30:17 +08:00
fix: ensure active assistant is updated correctly on deletion (#3588)
- Modified the assistant deletion logic to check if the deleted assistant is the currently active one before updating the active assistant state. This prevents potential issues when the active assistant is removed.
This commit is contained in:
parent
202894ab20
commit
f0b0bd8959
@ -31,11 +31,13 @@ const Assistants: FC<AssistantsTabProps> = ({
|
||||
const onDelete = useCallback(
|
||||
(assistant: Assistant) => {
|
||||
const remaining = assistants.filter((a) => a.id !== assistant.id)
|
||||
const newActive = remaining[remaining.length - 1]
|
||||
newActive ? setActiveAssistant(newActive) : onCreateDefaultAssistant()
|
||||
if (assistant.id === activeAssistant?.id) {
|
||||
const newActive = remaining[remaining.length - 1]
|
||||
newActive ? setActiveAssistant(newActive) : onCreateDefaultAssistant()
|
||||
}
|
||||
removeAssistant(assistant.id)
|
||||
},
|
||||
[assistants, removeAssistant, setActiveAssistant, onCreateDefaultAssistant]
|
||||
[activeAssistant, assistants, removeAssistant, setActiveAssistant, onCreateDefaultAssistant]
|
||||
)
|
||||
|
||||
return (
|
||||
|
||||
Loading…
Reference in New Issue
Block a user