()
| 75 | }; |
| 76 | |
| 77 | export const useUpdateConfig = () => { |
| 78 | let client = useQueryClient(); |
| 79 | |
| 80 | return useMutation({ |
| 81 | mutationFn: (config: AppConfig) => { |
| 82 | return updateConfig(config); |
| 83 | }, |
| 84 | onMutate: async (config: AppConfig) => { |
| 85 | await client.cancelQueries(['config']); |
| 86 | const previousConfig = client.getQueryData(['config']); |
| 87 | client.setQueryData(['config'], config); |
| 88 | return { previousConfig }; |
| 89 | }, |
| 90 | onError: (err, newMeta, context) => { |
| 91 | console.error('onError', err); |
| 92 | client.setQueryData(['config'], context.previousConfig); |
| 93 | }, |
| 94 | }); |
| 95 | }; |
| 96 | |
| 97 | interface ConnectionInfo { |
| 98 | settings: Array<{ |
no test coverage detected