mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2025-12-29 14:31:35 +08:00
refactor(useAgent): simplify mutate call in agent update
The previous implementation unnecessarily spread the previous state when only the result is needed. This simplifies the mutation logic while maintaining the same behavior.
This commit is contained in:
parent
8ead4e9c0f
commit
b5ef8a93ca
@ -24,10 +24,7 @@ export const useAgent = (id: string | null) => {
|
||||
try {
|
||||
// may change to optimistic update
|
||||
const result = await client.updateAgent(form)
|
||||
mutate((prev) => ({
|
||||
...prev,
|
||||
...result
|
||||
}))
|
||||
mutate(result)
|
||||
window.toast.success(t('common.update_success'))
|
||||
} catch (error) {
|
||||
window.toast.error(formatErrorMessageWithPrefix(error, t('agent.update.error.failed')))
|
||||
|
||||
Loading…
Reference in New Issue
Block a user