Fix sign up (#5231)

Sign up was broken by #5199
This commit is contained in:
Charles Bochet 2024-04-30 18:48:07 +02:00 committed by GitHub
parent 3fc48feefb
commit b7c2f83abf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -2,6 +2,7 @@ import { useEffect } from 'react';
import { useRecoilState, useRecoilValue } from 'recoil';
import { currentUserState } from '@/auth/states/currentUserState';
import { currentWorkspaceState } from '@/auth/states/currentWorkspaceState';
import { useFindManyObjectMetadataItems } from '@/object-metadata/hooks/useFindManyObjectMetadataItems';
import { objectMetadataItemsState } from '@/object-metadata/states/objectMetadataItemsState';
import { getObjectMetadataItemsMock } from '@/object-metadata/utils/getObjectMetadataItemsMock';
@ -10,6 +11,8 @@ import { isUndefinedOrNull } from '~/utils/isUndefinedOrNull';
export const ObjectMetadataItemsLoadEffect = () => {
const currentUser = useRecoilValue(currentUserState);
const currentWorkspace = useRecoilValue(currentWorkspaceState);
const { objectMetadataItems: newObjectMetadataItems } =
useFindManyObjectMetadataItems({
skip: isUndefinedOrNull(currentUser),
@ -20,14 +23,17 @@ export const ObjectMetadataItemsLoadEffect = () => {
);
useEffect(() => {
const toSetObjectMetadataItems = isUndefinedOrNull(currentUser)
? getObjectMetadataItemsMock()
: newObjectMetadataItems;
const toSetObjectMetadataItems =
isUndefinedOrNull(currentUser) ||
currentWorkspace?.activationStatus !== 'active'
? getObjectMetadataItemsMock()
: newObjectMetadataItems;
if (!isDeeplyEqual(objectMetadataItems, toSetObjectMetadataItems)) {
setObjectMetadataItems(toSetObjectMetadataItems);
}
}, [
currentUser,
currentWorkspace?.activationStatus,
newObjectMetadataItems,
objectMetadataItems,
setObjectMetadataItems,