refactor(agents): replace useMutation with simpler implementation in useRemoveAgent

This commit is contained in:
icarus 2025-09-18 18:08:45 +08:00
parent 64ee5c528b
commit 2b76c326ee

View File

@ -1,16 +1,12 @@
import { AgentEntity } from '@renderer/types'
import { useMutation, useQueryClient } from '@tanstack/react-query'
// import { useSWRConfig } from 'swr'
export const useRemoveAgent = () => {
const qc = useQueryClient()
// TODO: use api
return useMutation({
mutationFn: async (id: string) => {
return id
// const { mutate } = useSWRConfig()
return {
removeAgent: () => {
// not implemented
window.toast.info('Not implemented')
},
onSuccess: (deletedId: string) => {
qc.setQueryData<AgentEntity[]>(['agents'], (old) => old?.filter((t) => t.id !== deletedId))
}
})
status: {}
}
}