The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
Fix View creation, view fields re-ordering, view filters and view sorts erratic behaviors (#4800)
Charles Bochetb1a586d32487
diff --git a/packages/twenty-front/src/modules/views/hooks/useGetViewFromCache.ts b/packages/twenty-front/src/modules/views/hooks/useGetViewFromCache.tsindex 9d8aca3b1f1..273b5fde614 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<any>(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<View>(viewId, cache);},[cache, getRecordFromCache],);