Skip to content

Commit

Permalink
Fixed CI and removed unused code
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasbordeau committed Jan 15, 2025
1 parent 4071d7d commit b303f4b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,24 @@ import { EMPTY_QUERY } from '@/object-record/constants/EmptyQuery';
import { RecordGqlOperationSignature } from '@/object-record/graphql/types/RecordGqlOperationSignature';
import { useGenerateCombinedFindManyRecordsQuery } from '@/object-record/multiple-objects/hooks/useGenerateCombinedFindManyRecordsQuery';
import { MultiObjectRecordQueryResult } from '@/object-record/relation-picker/hooks/useMultiObjectRecordsQueryResultFormattedAsObjectRecordForSelectArray';
import { useEffect, useMemo } from 'react';
import { isDeeplyEqual } from '~/utils/isDeeplyEqual';

export const useCombinedFindManyRecords = ({
operationSignatures,
skip = false,
onDataChange,
}: {
operationSignatures: RecordGqlOperationSignature[];
skip?: boolean;
onDataChange?: (
data: MultiObjectRecordQueryResult | null | undefined,
) => void;
}) => {
const findManyQuery = useGenerateCombinedFindManyRecordsQuery({
operationSignatures,
});

const { data, loading, previousData } =
useQuery<MultiObjectRecordQueryResult>(findManyQuery ?? EMPTY_QUERY, {
const { data, loading } = useQuery<MultiObjectRecordQueryResult>(
findManyQuery ?? EMPTY_QUERY,
{
skip,
});
},
);

const resultWithoutConnection = Object.fromEntries(
Object.entries(data ?? {}).map(([namePlural, objectRecordConnection]) => [
Expand All @@ -37,20 +33,8 @@ export const useCombinedFindManyRecords = ({
]),
);

const isSameDataAsPreviousData = useMemo(
() => isDeeplyEqual(previousData, data),
[previousData, data],
);

useEffect(() => {
if (!isSameDataAsPreviousData) {
onDataChange?.(data);
}
}, [isSameDataAsPreviousData, onDataChange, data]);

return {
result: resultWithoutConnection,
loading,
isSameDataAsPreviousData,
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { mockedApolloClient } from '~/testing/mockedApolloClient';

import { RecoilDebugObserverEffect } from '@/debug/components/RecoilDebugObserver';
import { ObjectMetadataItemsProvider } from '@/object-metadata/components/ObjectMetadataItemsProvider';
import { RecordFiltersComponentInstanceContext } from '@/object-record/record-filter/states/context/RecordFiltersComponentInstanceContext';
import { PrefetchDataProvider } from '@/prefetch/components/PrefetchDataProvider';
import { WorkspaceProviderEffect } from '@/workspace/components/WorkspaceProviderEffect';
import { IconsProvider } from 'twenty-ui';
Expand Down Expand Up @@ -82,7 +83,13 @@ const Providers = () => {
<SnackBarProviderScope snackBarManagerScopeId="snack-bar-manager">
<IconsProvider>
<PrefetchDataProvider>
<Outlet />
<RecordFiltersComponentInstanceContext.Provider
value={{
instanceId: 'storybook-test-record-filters',
}}
>
<Outlet />
</RecordFiltersComponentInstanceContext.Provider>
</PrefetchDataProvider>
</IconsProvider>
</SnackBarProviderScope>
Expand Down

0 comments on commit b303f4b

Please sign in to comment.