1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-12-22 19:07:54 +01:00

fix: don't always fetch all flags on project flag screen (#7834)

There's a bug where the UI will fetch all features every time you load a
project screen (including every time you filter the project results).

The reason is that the create flag dialog was rendered (just not open)
every time. To solve it, we instead wrap it in an extra component that
prevents all the fetching and setup from running when the dialog isn't
open.

Additionally, we'll lower the page size for the global fetch limit to 1,
so that we send less data.
This commit is contained in:
Thomas Heartman 2024-08-12 11:07:36 +02:00 committed by GitHub
parent 17d25c65d6
commit 99f878d725
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -79,6 +79,17 @@ const configButtonData = {
export const CreateFeatureDialog = ({
open,
onClose,
}: ICreateFeatureDialogProps) => {
if (open) {
// wrap the inner component so that we only fetch data etc
// when the dialog is actually open.
return <CreateFeatureDialogContent open={open} onClose={onClose} />;
}
};
const CreateFeatureDialogContent = ({
open,
onClose,
}: ICreateFeatureDialogProps) => {
const { setToastData, setToastApiError } = useToast();
const { setShowFeedback } = useContext(UIContext);
@ -158,7 +169,7 @@ export const CreateFeatureDialog = ({
};
const { total: totalFlags, loading: loadingTotalFlagCount } =
useGlobalFeatureSearch();
useGlobalFeatureSearch(1);
const { project: projectInfo } = useProjectOverview(project);
const { tags: allTags } = useAllTags();