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 { useApolloClient, useMutation } from '@apollo/client';
|
||||
import { getOperationName } from '@apollo/client/utilities';
|
||||
|
||||
import {
|
||||
UpdateOneFieldMetadataItemMutation,
|
||||
@ -7,9 +6,9 @@ import {
|
||||
} from '~/generated-metadata/graphql';
|
||||
|
||||
import { UPDATE_ONE_FIELD_METADATA_ITEM } from '../graphql/mutations';
|
||||
import { FIND_MANY_OBJECT_METADATA_ITEMS } from '../graphql/queries';
|
||||
|
||||
import { currentWorkspaceState } from '@/auth/states/currentWorkspaceState';
|
||||
import { useRefreshObjectMetadataItems } from '@/object-metadata/hooks/useRefreshObjectMetadataItem';
|
||||
import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular';
|
||||
import { useFindManyRecordsQuery } from '@/object-record/hooks/useFindManyRecordsQuery';
|
||||
import { GET_CURRENT_USER } from '@/users/graphql/queries/getCurrentUser';
|
||||
@ -19,6 +18,8 @@ import { useApolloMetadataClient } from './useApolloMetadataClient';
|
||||
export const useUpdateOneFieldMetadataItem = () => {
|
||||
const apolloMetadataClient = useApolloMetadataClient();
|
||||
const apolloClient = useApolloClient();
|
||||
const { refreshObjectMetadataItems } =
|
||||
useRefreshObjectMetadataItems('network-only');
|
||||
|
||||
const setCurrentWorkspace = useSetRecoilState(currentWorkspaceState);
|
||||
|
||||
@ -67,10 +68,10 @@ export const useUpdateOneFieldMetadataItem = () => {
|
||||
idToUpdate: fieldMetadataIdToUpdate,
|
||||
updatePayload: updatePayload,
|
||||
},
|
||||
awaitRefetchQueries: true,
|
||||
refetchQueries: [getOperationName(FIND_MANY_OBJECT_METADATA_ITEMS) ?? ''],
|
||||
});
|
||||
|
||||
await refreshObjectMetadataItems();
|
||||
|
||||
const { data } = await apolloClient.query({ query: GET_CURRENT_USER });
|
||||
setCurrentWorkspace(data?.currentUser?.defaultWorkspace);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user