diff --git a/packages/twenty-front/src/modules/apollo/optimistic-effect/hooks/__tests__/useOptimisticEvict.test.tsx b/packages/twenty-front/src/modules/apollo/optimistic-effect/hooks/__tests__/useOptimisticEvict.test.tsx deleted file mode 100644 index 64834e745..000000000 --- a/packages/twenty-front/src/modules/apollo/optimistic-effect/hooks/__tests__/useOptimisticEvict.test.tsx +++ /dev/null @@ -1,50 +0,0 @@ -import { useApolloClient } from '@apollo/client'; -import { MockedProvider } from '@apollo/client/testing'; -import { act, renderHook } from '@testing-library/react'; -import { RecoilRoot } from 'recoil'; - -import { useOptimisticEvict } from '@/apollo/optimistic-effect/hooks/useOptimisticEvict'; - -const Wrapper = ({ children }: { children: React.ReactNode }) => ( - - {children} - -); - -describe('useOptimisticEvict', () => { - it('should perform cache eviction', async () => { - const mockedData = { - 'someType:1': { __typename: 'someType', id: '1', fieldName: 'value1' }, - 'someType:2': { __typename: 'someType', id: '2', fieldName: 'value2' }, - 'otherType:1': { __typename: 'otherType', id: '1', fieldName: 'value3' }, - }; - - const { result } = renderHook( - () => { - const { cache } = useApolloClient(); - cache.restore(mockedData); - - return { - ...useOptimisticEvict(), - cache, - }; - }, - { - wrapper: Wrapper, - }, - ); - - const { performOptimisticEvict, cache } = result.current; - - act(() => { - performOptimisticEvict('someType', 'fieldName', 'value1'); - }); - - const cacheSnapshot = cache.extract(); - - expect(cacheSnapshot).toEqual({ - 'someType:2': { __typename: 'someType', id: '2', fieldName: 'value2' }, - 'otherType:1': { __typename: 'otherType', id: '1', fieldName: 'value3' }, - }); - }); -}); diff --git a/packages/twenty-front/src/modules/apollo/optimistic-effect/hooks/useOptimisticEvict.ts b/packages/twenty-front/src/modules/apollo/optimistic-effect/hooks/useOptimisticEvict.ts deleted file mode 100644 index 97759f47a..000000000 --- a/packages/twenty-front/src/modules/apollo/optimistic-effect/hooks/useOptimisticEvict.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { useApolloClient } from '@apollo/client'; - -export const useOptimisticEvict = () => { - const cache = useApolloClient().cache; - - const performOptimisticEvict = ( - typename: string, - fieldName: string, - fieldValue: string, - ) => { - const serializedCache = cache.extract(); - - Object.values(serializedCache) - .filter((item) => item.__typename === typename) - .forEach((item) => { - if (item[fieldName] === fieldValue) { - cache.evict({ id: cache.identify(item) }); - } - }); - }; - return { - performOptimisticEvict, - }; -}; diff --git a/packages/twenty-front/src/pages/settings/developers/SettingsDevelopersApiKeyDetail.tsx b/packages/twenty-front/src/pages/settings/developers/SettingsDevelopersApiKeyDetail.tsx index 5e1057669..bde08614e 100644 --- a/packages/twenty-front/src/pages/settings/developers/SettingsDevelopersApiKeyDetail.tsx +++ b/packages/twenty-front/src/pages/settings/developers/SettingsDevelopersApiKeyDetail.tsx @@ -4,7 +4,6 @@ import styled from '@emotion/styled'; import { DateTime } from 'luxon'; import { useRecoilState } from 'recoil'; -import { useOptimisticEvict } from '@/apollo/optimistic-effect/hooks/useOptimisticEvict'; import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular'; import { useCreateOneRecord } from '@/object-record/hooks/useCreateOneRecord'; import { useFindOneRecord } from '@/object-record/hooks/useFindOneRecord'; @@ -48,8 +47,6 @@ export const SettingsDevelopersApiKeyDetail = () => { const [generatedApiKey] = useRecoilState( generatedApiKeyFamilyState(apiKeyId), ); - const { performOptimisticEvict } = useOptimisticEvict(); - const [generateOneApiKeyToken] = useGenerateApiKeyTokenMutation(); const { createOneRecord: createOneApiKey } = useCreateOneRecord({ objectNameSingular: CoreObjectNameSingular.ApiKey, @@ -68,7 +65,6 @@ export const SettingsDevelopersApiKeyDetail = () => { idToUpdate: apiKeyId, updateOneRecordInput: { revokedAt: DateTime.now().toString() }, }); - performOptimisticEvict('ApiKey', 'id', apiKeyId); if (redirect) { navigate('/settings/developers'); } diff --git a/packages/twenty-front/src/pages/settings/developers/SettingsDevelopersApiKeys.tsx b/packages/twenty-front/src/pages/settings/developers/SettingsDevelopersApiKeys.tsx index 4946e5254..a9c74c195 100644 --- a/packages/twenty-front/src/pages/settings/developers/SettingsDevelopersApiKeys.tsx +++ b/packages/twenty-front/src/pages/settings/developers/SettingsDevelopersApiKeys.tsx @@ -36,7 +36,6 @@ export const SettingsDevelopersApiKeys = () => { const { records: apiKeys } = useFindManyRecords({ objectNameSingular: CoreObjectNameSingular.ApiKey, filter: { revokedAt: { is: 'NULL' } }, - orderBy: {}, }); return ( diff --git a/packages/twenty-front/src/pages/settings/developers/SettingsDevelopersWebhooks.tsx b/packages/twenty-front/src/pages/settings/developers/SettingsDevelopersWebhooks.tsx index efd1a666b..31a59129b 100644 --- a/packages/twenty-front/src/pages/settings/developers/SettingsDevelopersWebhooks.tsx +++ b/packages/twenty-front/src/pages/settings/developers/SettingsDevelopersWebhooks.tsx @@ -33,7 +33,6 @@ export const SettingsDevelopersWebhooks = () => { const { records: webhooks } = useFindManyRecords({ objectNameSingular: CoreObjectNameSingular.Webhook, - orderBy: {}, }); return (