Skip to content

Commit

Permalink
Remove useless hook
Browse files Browse the repository at this point in the history
  • Loading branch information
martmull committed Dec 18, 2024
1 parent 2f6fdc9 commit 12ba448
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 188 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@ import { useFavorites } from '@/favorites/hooks/useFavorites';
import { ObjectMetadataItem } from '@/object-metadata/types/ObjectMetadataItem';
import { DELETE_MAX_COUNT } from '@/object-record/constants/DeleteMaxCount';
import { useDeleteManyRecords } from '@/object-record/hooks/useDeleteManyRecords';
import { useFetchAllRecordIds } from '@/object-record/hooks/useFetchAllRecordIds';
import { useRecordTable } from '@/object-record/record-table/hooks/useRecordTable';
import { ConfirmationModal } from '@/ui/layout/modal/components/ConfirmationModal';
import { useRightDrawer } from '@/ui/layout/right-drawer/hooks/useRightDrawer';
import { useRecoilComponentValueV2 } from '@/ui/utilities/state/component-state/hooks/useRecoilComponentValueV2';
import { useCallback, useContext, useState } from 'react';
import { IconTrash, isDefined } from 'twenty-ui';
import { useLazyFetchAllRecords } from '@/object-record/hooks/useLazyFetchAllRecords';
import { DEFAULT_QUERY_PAGE_SIZE } from '@/object-record/constants/DefaultQueryPageSize';

export const useDeleteMultipleRecordsAction = ({
objectMetadataItem,
Expand Down Expand Up @@ -60,15 +61,18 @@ export const useDeleteMultipleRecordsAction = ({
objectMetadataItem,
);

const { fetchAllRecordIds } = useFetchAllRecordIds({
const { fetchAllRecords: fetchAllRecordIds } = useLazyFetchAllRecords({
objectNameSingular: objectMetadataItem.nameSingular,
filter: graphqlFilter,
limit: DEFAULT_QUERY_PAGE_SIZE,
recordGqlFields: { id: true },
});

const { closeRightDrawer } = useRightDrawer();

const handleDeleteClick = useCallback(async () => {
const recordIdsToDelete = await fetchAllRecordIds();
const recordsToDelete = await fetchAllRecordIds();
const recordIdsToDelete = recordsToDelete.map((record) => record.id);

resetTableRowSelection();

Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ export const useLazyFetchAllRecords = <T>({
const recordsCount = firstQueryResult?.edges.length ?? 0;

const records = firstQueryResult?.edges?.map((edge) => edge.node) ?? [];

setProgress({
exportedRecordCount: recordsCount,
totalRecordCount: totalCount,
Expand Down Expand Up @@ -97,7 +98,6 @@ export const useLazyFetchAllRecords = <T>({
const fetchMoreResult = rawResult?.data?.[objectMetadataItem.namePlural];

for (const edge of fetchMoreResult.edges) {
console.log(edge.node);
records.push(edge.node);
}

Expand Down

0 comments on commit 12ba448

Please sign in to comment.