Fixed RecordShowEffect request bug (#12247)
This PR fixes the RecordShowEffect that was overwriting the record store with an empty state during the request loading time.
This commit is contained in:
@ -6,6 +6,7 @@ import { recordStoreFamilyState } from '@/object-record/record-store/states/reco
|
|||||||
import { ObjectRecord } from '@/object-record/types/ObjectRecord';
|
import { ObjectRecord } from '@/object-record/types/ObjectRecord';
|
||||||
import { useEffect } from 'react';
|
import { useEffect } from 'react';
|
||||||
import { useRecoilCallback } from 'recoil';
|
import { useRecoilCallback } from 'recoil';
|
||||||
|
import { isDefined } from 'twenty-shared/utils';
|
||||||
|
|
||||||
type RecordShowEffectProps = {
|
type RecordShowEffectProps = {
|
||||||
objectNameSingular: string;
|
objectNameSingular: string;
|
||||||
@ -25,7 +26,7 @@ export const RecordShowEffect = ({
|
|||||||
objectMetadataItems,
|
objectMetadataItems,
|
||||||
});
|
});
|
||||||
|
|
||||||
const { record } = useFindOneRecord({
|
const { record, loading } = useFindOneRecord({
|
||||||
objectRecordId: recordId,
|
objectRecordId: recordId,
|
||||||
objectNameSingular,
|
objectNameSingular,
|
||||||
recordGqlFields: FIND_ONE_RECORD_FOR_SHOW_PAGE_OPERATION_SIGNATURE.fields,
|
recordGqlFields: FIND_ONE_RECORD_FOR_SHOW_PAGE_OPERATION_SIGNATURE.fields,
|
||||||
@ -47,8 +48,10 @@ export const RecordShowEffect = ({
|
|||||||
);
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setRecordStore(record);
|
if (!loading && isDefined(record)) {
|
||||||
}, [record, setRecordStore]);
|
setRecordStore(record);
|
||||||
|
}
|
||||||
|
}, [record, setRecordStore, loading]);
|
||||||
|
|
||||||
return <></>;
|
return <></>;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user