From 73f1d3caa3697d72eba9a616c14285f1c0cffd4f Mon Sep 17 00:00:00 2001 From: Samuel Bodin <1637651+bodinsamuel@users.noreply.github.com> Date: Tue, 24 Sep 2024 17:10:38 +0200 Subject: [PATCH] fix(ui): clear cache on integration save (#2759) ## Describe your changes Fixes https://linear.app/nango/issue/NAN-1784/refresh-cache-on-integration-save - Refresh cache when we save integration credentials --- .../Integrations/providerConfigKey/Settings/components/App.tsx | 2 ++ .../providerConfigKey/Settings/components/Custom.tsx | 2 ++ .../providerConfigKey/Settings/components/OAuth.tsx | 2 ++ 3 files changed, 6 insertions(+) diff --git a/packages/webapp/src/pages/Integrations/providerConfigKey/Settings/components/App.tsx b/packages/webapp/src/pages/Integrations/providerConfigKey/Settings/components/App.tsx index 7894b009b6a..b7a41b79e4f 100644 --- a/packages/webapp/src/pages/Integrations/providerConfigKey/Settings/components/App.tsx +++ b/packages/webapp/src/pages/Integrations/providerConfigKey/Settings/components/App.tsx @@ -10,6 +10,7 @@ import { useState } from 'react'; import { useStore } from '../../../../../store'; import { apiPatchIntegration } from '../../../../../hooks/useIntegration'; import { useToast } from '../../../../../hooks/useToast'; +import { mutate } from 'swr'; export const SettingsApp: React.FC<{ data: GetIntegration['Success']['data']; environment: EnvironmentAndAccount['environment'] }> = ({ data: { integration }, @@ -32,6 +33,7 @@ export const SettingsApp: React.FC<{ data: GetIntegration['Success']['data']; en toast({ title: updated.json.error.message || 'Failed to update, an error occurred', variant: 'error' }); } else { toast({ title: 'Successfully updated integration', variant: 'success' }); + void mutate((key) => typeof key === 'string' && key.startsWith(`/api/v1/integrations`)); } setLoading(false); diff --git a/packages/webapp/src/pages/Integrations/providerConfigKey/Settings/components/Custom.tsx b/packages/webapp/src/pages/Integrations/providerConfigKey/Settings/components/Custom.tsx index c4ec65c25e2..68a275e1554 100644 --- a/packages/webapp/src/pages/Integrations/providerConfigKey/Settings/components/Custom.tsx +++ b/packages/webapp/src/pages/Integrations/providerConfigKey/Settings/components/Custom.tsx @@ -12,6 +12,7 @@ import { useStore } from '../../../../../store'; import SecretTextarea from '../../../../../components/ui/input/SecretTextArea'; import { apiPatchIntegration } from '../../../../../hooks/useIntegration'; import { useToast } from '../../../../../hooks/useToast'; +import { mutate } from 'swr'; export const SettingsCustom: React.FC<{ data: GetIntegration['Success']['data']; environment: EnvironmentAndAccount['environment'] }> = ({ data: { integration }, @@ -36,6 +37,7 @@ export const SettingsCustom: React.FC<{ data: GetIntegration['Success']['data']; toast({ title: updated.json.error.message || 'Failed to update, an error occurred', variant: 'error' }); } else { toast({ title: 'Successfully updated integration', variant: 'success' }); + void mutate((key) => typeof key === 'string' && key.startsWith(`/api/v1/integrations`)); } setLoading(false); diff --git a/packages/webapp/src/pages/Integrations/providerConfigKey/Settings/components/OAuth.tsx b/packages/webapp/src/pages/Integrations/providerConfigKey/Settings/components/OAuth.tsx index bb0bda8bb5a..b735d2a0c98 100644 --- a/packages/webapp/src/pages/Integrations/providerConfigKey/Settings/components/OAuth.tsx +++ b/packages/webapp/src/pages/Integrations/providerConfigKey/Settings/components/OAuth.tsx @@ -12,6 +12,7 @@ import { useStore } from '../../../../../store'; import TagsInput from '../../../../../components/ui/input/TagsInput'; import { apiPatchIntegration } from '../../../../../hooks/useIntegration'; import { useToast } from '../../../../../hooks/useToast'; +import { mutate } from 'swr'; export const SettingsOAuth: React.FC<{ data: GetIntegration['Success']['data']; environment: EnvironmentAndAccount['environment'] }> = ({ data: { integration, template }, @@ -33,6 +34,7 @@ export const SettingsOAuth: React.FC<{ data: GetIntegration['Success']['data']; if ('error' in updated.json) { toast({ title: updated.json.error.message || 'Failed to update, an error occurred', variant: 'error' }); } else { + void mutate((key) => typeof key === 'string' && key.startsWith(`/api/v1/integrations`)); toast({ title: 'Successfully updated integration', variant: 'success' }); }