Move settings data model refreshMetadata to sync calls (#9046)
In this PR, I'm - removing setting up the isAppWaitingForFreshMetadata boolean state in PageChangeEffect navigate (not robust) to some precise synchronous places, improving the control we have on when the app considers it's ready to be rendered based on fresh metadata - fixing tests
This commit is contained in:
@ -1,5 +1,4 @@
|
||||
import { useMutation } from '@apollo/client';
|
||||
import { getOperationName } from '@apollo/client/utilities';
|
||||
|
||||
import {
|
||||
CreateOneRelationMetadataMutation,
|
||||
@ -7,12 +6,12 @@ import {
|
||||
} from '~/generated-metadata/graphql';
|
||||
|
||||
import { CREATE_ONE_RELATION_METADATA_ITEM } from '../graphql/mutations';
|
||||
import { FIND_MANY_OBJECT_METADATA_ITEMS } from '../graphql/queries';
|
||||
import {
|
||||
formatRelationMetadataInput,
|
||||
FormatRelationMetadataInputParams,
|
||||
} from '../utils/formatRelationMetadataInput';
|
||||
|
||||
import { useRefreshObjectMetadataItems } from '@/object-metadata/hooks/useRefreshObjectMetadataItem';
|
||||
import { useApolloMetadataClient } from './useApolloMetadataClient';
|
||||
|
||||
export const useCreateOneRelationMetadataItem = () => {
|
||||
@ -25,14 +24,19 @@ export const useCreateOneRelationMetadataItem = () => {
|
||||
client: apolloMetadataClient,
|
||||
});
|
||||
|
||||
const { refreshObjectMetadataItems } =
|
||||
useRefreshObjectMetadataItems('network-only');
|
||||
|
||||
const createOneRelationMetadataItem = async (
|
||||
input: FormatRelationMetadataInputParams,
|
||||
) => {
|
||||
return await mutate({
|
||||
const result = await mutate({
|
||||
variables: { input: { relation: formatRelationMetadataInput(input) } },
|
||||
awaitRefetchQueries: true,
|
||||
refetchQueries: [getOperationName(FIND_MANY_OBJECT_METADATA_ITEMS) ?? ''],
|
||||
});
|
||||
|
||||
await refreshObjectMetadataItems();
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user