mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2025-12-22 00:13:09 +08:00
feat(agents): add success toast notifications for agent operations
This commit is contained in:
parent
eaa5ec5545
commit
a424e3a039
@ -21,6 +21,7 @@ export const useAgents = () => {
|
|||||||
try {
|
try {
|
||||||
const result = await client.createAgent(form)
|
const result = await client.createAgent(form)
|
||||||
mutate((prev) => [...(prev ?? []), result])
|
mutate((prev) => [...(prev ?? []), result])
|
||||||
|
window.toast.success(t('common.add_success'))
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
window.toast.error(formatErrorMessageWithPrefix(error, t('agent.add.error.failed')))
|
window.toast.error(formatErrorMessageWithPrefix(error, t('agent.add.error.failed')))
|
||||||
}
|
}
|
||||||
@ -34,6 +35,7 @@ export const useAgents = () => {
|
|||||||
// may change to optimistic update
|
// may change to optimistic update
|
||||||
const result = await client.updateAgent(form)
|
const result = await client.updateAgent(form)
|
||||||
mutate((prev) => prev?.map((a) => (a.id === result.id ? result : a)) ?? [])
|
mutate((prev) => prev?.map((a) => (a.id === result.id ? result : a)) ?? [])
|
||||||
|
window.toast.success(t('common.update_success'))
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
window.toast.error(formatErrorMessageWithPrefix(error, t('agent.update.error.failed')))
|
window.toast.error(formatErrorMessageWithPrefix(error, t('agent.update.error.failed')))
|
||||||
}
|
}
|
||||||
@ -46,6 +48,7 @@ export const useAgents = () => {
|
|||||||
try {
|
try {
|
||||||
await client.deleteAgent(id)
|
await client.deleteAgent(id)
|
||||||
mutate((prev) => prev?.filter((a) => a.id !== id) ?? [])
|
mutate((prev) => prev?.filter((a) => a.id !== id) ?? [])
|
||||||
|
window.toast.success(t('common.delete_success'))
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
window.toast.error(formatErrorMessageWithPrefix(error, t('agent.delete.error.failed')))
|
window.toast.error(formatErrorMessageWithPrefix(error, t('agent.delete.error.failed')))
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user