mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2025-12-29 23:12:38 +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 { 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: {}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user