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 { 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)) }
}
})
} }