fix: invalidate app connections upon creating a connection

This commit is contained in:
Rıdvan Akca
2024-04-12 11:45:12 +02:00
parent 61dc431f92
commit d9917a81bb

View File

@@ -17,6 +17,7 @@ import useFormatMessage from 'hooks/useFormatMessage';
import { generateExternalLink } from 'helpers/translationValues'; import { generateExternalLink } from 'helpers/translationValues';
import { Form } from './style'; import { Form } from './style';
import useAppAuth from 'hooks/useAppAuth'; import useAppAuth from 'hooks/useAppAuth';
import { useQueryClient } from '@tanstack/react-query';
function AddAppConnection(props) { function AddAppConnection(props) {
const { application, connectionId, onClose } = props; const { application, connectionId, onClose } = props;
@@ -36,6 +37,7 @@ function AddAppConnection(props) {
appAuthClientId, appAuthClientId,
useShared: !!appAuthClientId, useShared: !!appAuthClientId,
}); });
const queryClient = useQueryClient();
React.useEffect(function relayProviderData() { React.useEffect(function relayProviderData() {
if (window.opener) { if (window.opener) {
@@ -78,6 +80,10 @@ function AddAppConnection(props) {
const response = await authenticate({ const response = await authenticate({
fields: data, fields: data,
}); });
await queryClient.invalidateQueries({
queryKey: ['apps', key, 'connections'],
});
onClose(response); onClose(response);
} catch (err) { } catch (err) {
const error = err; const error = err;