In this PR: - take feedbacks from: https://github.com/twentyhq/twenty/pull/6530 / https://github.com/twentyhq/twenty/pull/6529 / https://github.com/twentyhq/twenty/pull/6526 / https://github.com/twentyhq/twenty/pull/6512 - refactor onboarding uservars to be absent when the user is fully onboarded: isStepComplete ==> isStepIncomplete - introduce a new workspace.activationStatus: CREATION_ONGOING I'm retesting the whole flow: - with/without BILLING - sign in with/without SSO - sign up with/without SSO - another workspaceMembers join the team - subscriptionCanceled - access to billingPortal
38 lines
1.3 KiB
TypeScript
38 lines
1.3 KiB
TypeScript
import { useRecoilValue } from 'recoil';
|
|
|
|
import { useObjectMetadataItem } from '@/object-metadata/hooks/useObjectMetadataItem';
|
|
import { RecordGqlOperationFilter } from '@/object-record/graphql/types/RecordGqlOperationFilter';
|
|
import { useFindManyRecords } from '@/object-record/hooks/useFindManyRecords';
|
|
import { ObjectRecord } from '@/object-record/types/ObjectRecord';
|
|
import { PREFETCH_CONFIG } from '@/prefetch/constants/PrefetchConfig';
|
|
import { prefetchIsLoadedFamilyState } from '@/prefetch/states/prefetchIsLoadedFamilyState';
|
|
import { PrefetchKey } from '@/prefetch/types/PrefetchKey';
|
|
|
|
export const usePrefetchedData = <T extends ObjectRecord>(
|
|
prefetchKey: PrefetchKey,
|
|
filter?: RecordGqlOperationFilter,
|
|
) => {
|
|
const isDataPrefetched = useRecoilValue(
|
|
prefetchIsLoadedFamilyState(prefetchKey),
|
|
);
|
|
|
|
const { operationSignatureFactory, objectNameSingular } =
|
|
PREFETCH_CONFIG[prefetchKey];
|
|
|
|
const { objectMetadataItem } = useObjectMetadataItem({
|
|
objectNameSingular,
|
|
});
|
|
|
|
const { records } = useFindManyRecords<T>({
|
|
skip: !isDataPrefetched,
|
|
objectNameSingular: objectNameSingular,
|
|
recordGqlFields:
|
|
operationSignatureFactory({ objectMetadataItem }).fields ?? filter,
|
|
});
|
|
|
|
return {
|
|
isDataPrefetched,
|
|
records,
|
|
};
|
|
};
|