mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2026-01-04 20:00:00 +08:00
refactor(agents): replace useMutation with simpler implementation in useRemoveAgent
This commit is contained in:
parent
64ee5c528b
commit
2b76c326ee
@ -1,16 +1,12 @@
|
|||||||
import { AgentEntity } from '@renderer/types'
|
// import { useSWRConfig } from 'swr'
|
||||||
import { useMutation, useQueryClient } from '@tanstack/react-query'
|
|
||||||
|
|
||||||
export const useRemoveAgent = () => {
|
export const useRemoveAgent = () => {
|
||||||
const qc = useQueryClient()
|
// const { mutate } = useSWRConfig()
|
||||||
|
return {
|
||||||
// TODO: use api
|
removeAgent: () => {
|
||||||
return useMutation({
|
// not implemented
|
||||||
mutationFn: async (id: string) => {
|
window.toast.info('Not implemented')
|
||||||
return id
|
|
||||||
},
|
},
|
||||||
onSuccess: (deletedId: string) => {
|
status: {}
|
||||||
qc.setQueryData<AgentEntity[]>(['agents'], (old) => old?.filter((t) => t.id !== deletedId))
|
}
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user