()
| 229 | } |
| 230 | |
| 231 | export function useCreateManagedAgentMutation() { |
| 232 | const queryClient = useQueryClient(); |
| 233 | |
| 234 | return useMutation({ |
| 235 | mutationFn: (input: CreateManagedAgentInput) => createManagedAgent(input), |
| 236 | onSuccess: (created) => { |
| 237 | queryClient.setQueryData<ManagedAgent[]>( |
| 238 | managedAgentsQueryKey, |
| 239 | (current) => { |
| 240 | const next = current ?? []; |
| 241 | |
| 242 | return [ |
| 243 | created.agent, |
| 244 | ...next.filter((agent) => agent.pubkey !== created.agent.pubkey), |
| 245 | ]; |
| 246 | }, |
| 247 | ); |
| 248 | }, |
| 249 | onSettled: async () => { |
| 250 | await queryClient.invalidateQueries({ queryKey: managedAgentsQueryKey }); |
| 251 | await queryClient.invalidateQueries({ queryKey: relayAgentsQueryKey }); |
| 252 | }, |
| 253 | }); |
| 254 | } |
| 255 | |
| 256 | export function useUpdateManagedAgentMutation() { |
| 257 | const queryClient = useQueryClient(); |
no test coverage detected