fix - newly added object not visible in left menu (#14202)

resolves #14190 

added refreshCoreViews() call after object creation to immediately
update core views state, ensuring new objects appear in the navigation
drawer without requiring a refresh

---------

Co-authored-by: Charles Bochet <charles@twenty.com>
Co-authored-by: prastoin <paul@twenty.com>
This commit is contained in:
Vinay Arvind Badgujar
2025-09-05 14:13:03 +05:30
committed by GitHub
parent 9746c3a787
commit 5824637d1a
72 changed files with 914 additions and 2581 deletions
@@ -9,13 +9,14 @@ import {
import { CREATE_ONE_OBJECT_METADATA_ITEM } from '../graphql/mutations';
import { useRefreshObjectMetadataItems } from '@/object-metadata/hooks/useRefreshObjectMetadataItems';
import { useRefreshCachedViews } from '@/views/hooks/useRefreshViews';
import { useRefreshCoreViewsByObjectMetadataId } from '@/views/hooks/useRefreshCoreViewsByObjectMetadataId';
import { isDefined } from 'twenty-shared/utils';
export const useCreateOneObjectMetadataItem = () => {
const { refreshCachedViews } = useRefreshCachedViews();
const { refreshObjectMetadataItems } =
useRefreshObjectMetadataItems('network-only');
const { refreshCoreViewsByObjectMetadataId } =
useRefreshCoreViewsByObjectMetadataId();
const [mutate] = useMutation<
CreateOneObjectMetadataItemMutation,
@@ -30,7 +31,13 @@ export const useCreateOneObjectMetadataItem = () => {
});
await refreshObjectMetadataItems();
refreshCachedViews();
if (isDefined(createdObjectMetadata.data?.createOneObject?.id)) {
await refreshCoreViewsByObjectMetadataId(
createdObjectMetadata.data.createOneObject.id,
);
}
return createdObjectMetadata;
};