Fix race condition while loading metadata on sign in (#9027)

This commit is contained in:
Charles Bochet
2024-12-11 18:56:02 +01:00
committed by GitHub
parent 183fd877c4
commit 90c26643a8
9 changed files with 89 additions and 33 deletions

View File

@ -0,0 +1,19 @@
import React from 'react';
import { useRecoilValue } from 'recoil';
import { isAppWaitingForFreshObjectMetadataState } from '@/object-metadata/states/isAppWaitingForFreshObjectMetadataState';
import { UserOrMetadataLoader } from '~/loading/components/UserOrMetadataLoader';
export const ObjectMetadataItemsGater = ({
children,
}: React.PropsWithChildren) => {
const isAppWaitingForFreshObjectMetadata = useRecoilValue(
isAppWaitingForFreshObjectMetadataState,
);
const shouldDisplayChildren = !isAppWaitingForFreshObjectMetadata;
return (
<>{shouldDisplayChildren ? <>{children}</> : <UserOrMetadataLoader />}</>
);
};