Skip to content

Commit

Permalink
fix: only call project overview from connect dialog when open (#8977)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
thomasheartman authored Dec 13, 2024
1 parent 63d2359 commit 428b0b3
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions frontend/src/component/onboarding/dialog/ConnectSdkDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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 ? (
Expand Down Expand Up @@ -199,3 +198,10 @@ export const ConnectSdkDialog = ({
</StyledDialog>
);
};

export const ConnectSdkDialog = ({
open,
...props
}: IConnectSDKDialogProps) => {
return open ? <InnerDialog {...props} /> : null;
};

0 comments on commit 428b0b3

Please sign in to comment.