diff --git a/packages/webapp/src/hooks/useConnections.tsx b/packages/webapp/src/hooks/useConnections.tsx index a3107ff546..6afd534467 100644 --- a/packages/webapp/src/hooks/useConnections.tsx +++ b/packages/webapp/src/hooks/useConnections.tsx @@ -39,7 +39,7 @@ export function useConnections(queries: GetConnections['Querystring']) { return { loading, error: error?.json, data, hasNext, offset: size, setOffset: setSize, mutate }; } -export function invalidateConnections(cache: Cache, mutate: ReturnType['mutate']) { +export function clearConnectionsCache(cache: Cache, mutate: ReturnType['mutate']) { for (const key of cache.keys()) { if (key.includes('/api/v1/connections?')) { void mutate(key, undefined); diff --git a/packages/webapp/src/pages/Integrations/providerConfigKey/Settings/components/Delete.tsx b/packages/webapp/src/pages/Integrations/providerConfigKey/Settings/components/Delete.tsx index d9027ea9ea..a8f2baf6c5 100644 --- a/packages/webapp/src/pages/Integrations/providerConfigKey/Settings/components/Delete.tsx +++ b/packages/webapp/src/pages/Integrations/providerConfigKey/Settings/components/Delete.tsx @@ -6,7 +6,7 @@ import { useToast } from '../../../../../hooks/useToast'; import { useNavigate } from 'react-router-dom'; import { useSWRConfig } from 'swr'; import { Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogTitle, DialogTrigger } from '../../../../../components/ui/Dialog'; -import { invalidateConnections } from '../../../../../hooks/useConnections'; +import { clearConnectionsCache } from '../../../../../hooks/useConnections'; export const DeleteIntegrationButton: React.FC<{ env: string; integration: ApiIntegration }> = ({ env, integration }) => { const { toast } = useToast(); @@ -27,7 +27,7 @@ export const DeleteIntegrationButton: React.FC<{ env: string; integration: ApiIn toast({ title: `Integration "${integration.unique_key}" has been deleted`, variant: 'success' }); void mutate((key) => typeof key === 'string' && key.startsWith(`/api/v1/integrations`), undefined); - invalidateConnections(cache, mutate); + clearConnectionsCache(cache, mutate); navigate(`/${env}/integrations`); } diff --git a/packages/webapp/src/pages/Integrations/providerConfigKey/Show.tsx b/packages/webapp/src/pages/Integrations/providerConfigKey/Show.tsx index 0ed64ae848..0cee9dee79 100644 --- a/packages/webapp/src/pages/Integrations/providerConfigKey/Show.tsx +++ b/packages/webapp/src/pages/Integrations/providerConfigKey/Show.tsx @@ -24,7 +24,7 @@ import { useToast } from '../../../hooks/useToast'; import { Helmet } from 'react-helmet'; import { ErrorPageComponent } from '../../../components/ErrorComponent'; import { useSWRConfig } from 'swr'; -import { invalidateConnections } from '../../../hooks/useConnections'; +import { clearConnectionsCache } from '../../../hooks/useConnections'; export const ShowIntegration: React.FC = () => { const { providerConfigKey } = useParams(); @@ -63,8 +63,6 @@ export const ShowIntegration: React.FC = () => { const onEvent: OnConnectEvent = useCallback( (event) => { if (event.type === 'close') { - invalidateConnections(cache, mutate); - if (hasConnected.current) { toast.toast({ title: `Connected to ${data?.integration.unique_key}`, variant: 'success' }); navigate(`/${env}/connections/${data?.integration.unique_key}/${hasConnected.current}`); @@ -72,7 +70,7 @@ export const ShowIntegration: React.FC = () => { } else if (event.type === 'connect') { console.log('connected', event); - invalidateConnections(cache, mutate); + clearConnectionsCache(cache, mutate); hasConnected.current = event.payload.connectionId; } },