1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-02-04 00:18:01 +01:00

fix: only call project overview from connect dialog when open (#8977)

Fixes a bug where we'd call the project overview every second when on a
project page.

The reason this happens is that the connect SDK dialog sets up a fetcher
to re-fetch it every second.

The request should only be fired when the dialog is open, but because of
the way it's set up, we we're setting up the repeated fetch regardless
of whether the dialog was open or not.

This PR moves the dialog and all it's content into a nested component
that's only rendered if the dialog should be opened.
This commit is contained in:
Thomas Heartman 2024-12-13 09:41:49 +01:00 committed by GitHub
parent 63d2359dec
commit 428b0b370b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -64,14 +64,13 @@ const NextStepSectionSpacedContainer = styled('div')(({ theme }) => ({
type OnboardingStage = 'select-sdk' | 'generate-api-key' | 'test-connection';
export const ConnectSdkDialog = ({
open,
const InnerDialog = ({
onClose,
onFinish,
environments,
project: projectId,
feature,
}: IConnectSDKDialogProps) => {
}: Omit<IConnectSDKDialogProps, 'open'>) => {
const theme = useTheme();
const isLargeScreen = useMediaQuery(theme.breakpoints.up('lg'));
const [sdk, setSdk] = useState<Sdk | null>(null);
@ -98,7 +97,7 @@ export const ConnectSdkDialog = ({
}, [JSON.stringify(environments)]);
return (
<StyledDialog open={open} onClose={onClose}>
<StyledDialog open={true} onClose={onClose}>
<Box sx={{ display: 'flex' }}>
<ConnectSdk>
{isSelectSdkStage ? (
@ -199,3 +198,10 @@ export const ConnectSdkDialog = ({
</StyledDialog>
);
};
export const ConnectSdkDialog = ({
open,
...props
}: IConnectSDKDialogProps) => {
return open ? <InnerDialog {...props} /> : null;
};