mirror of
https://github.com/twentyhq/twenty.git
synced 2024-11-27 11:03:40 +03:00
parent
3fc48feefb
commit
b7c2f83abf
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user