diff --git a/packages/twenty-front/src/modules/views/hooks/useGetViewFromCache.ts b/packages/twenty-front/src/modules/views/hooks/useGetViewFromCache.ts index 9d8aca3b1..273b5fde6 100644 --- a/packages/twenty-front/src/modules/views/hooks/useGetViewFromCache.ts +++ b/packages/twenty-front/src/modules/views/hooks/useGetViewFromCache.ts @@ -3,9 +3,7 @@ import { useApolloClient } from '@apollo/client'; import { useObjectMetadataItem } from '@/object-metadata/hooks/useObjectMetadataItem'; import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular'; -import { ObjectRecordEdge } from '@/object-record/types/ObjectRecordEdge'; -import { GraphQLView } from '@/views/types/GraphQLView'; -import { isUndefinedOrNull } from '~/utils/isUndefinedOrNull'; +import { View } from '@/views/types/View'; export const useGetViewFromCache = () => { const client = useApolloClient(); @@ -17,30 +15,7 @@ export const useGetViewFromCache = () => { const getViewFromCache = useCallback( async (viewId: string) => { - // Todo Fix typing once we have figured out record connections - const viewWithConnections = getRecordFromCache(viewId, cache); - - if (isUndefinedOrNull(viewWithConnections)) { - return; - } - - const view = { - ...viewWithConnections, - viewFilters: - viewWithConnections.viewFilters?.edges?.map( - (edge: ObjectRecordEdge) => edge.node, - ) ?? [], - viewSorts: - viewWithConnections.viewSorts?.edges?.map( - (edge: ObjectRecordEdge) => edge.node, - ) ?? [], - viewFields: - viewWithConnections.viewFields?.edges?.map( - (edge: ObjectRecordEdge) => edge.node, - ) ?? [], - } as GraphQLView; - - return view; + return getRecordFromCache(viewId, cache); }, [cache, getRecordFromCache], );