Fix race condition while loading metadata on sign in (#9027)
This commit is contained in:
@ -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 />}</>
|
||||
);
|
||||
};
|
||||
@ -0,0 +1,6 @@
|
||||
import { createState } from 'twenty-ui';
|
||||
|
||||
export const isAppWaitingForFreshObjectMetadataState = createState<boolean>({
|
||||
key: 'isAppWaitingForFreshObjectMetadataState',
|
||||
defaultValue: false,
|
||||
});
|
||||
Reference in New Issue
Block a user