mirror of
https://github.com/twentyhq/twenty.git
synced 2024-12-26 05:24:04 +03:00
Fix infinite loop on sign in
This commit is contained in:
parent
e89546466c
commit
d4613c87f6
@ -37,5 +37,6 @@ export const useOpenCreateActivityDrawerForSelectedRowIds = () => {
|
||||
targetableEntities: activityTargetableEntityArray,
|
||||
});
|
||||
},
|
||||
[openCreateActivityDrawer],
|
||||
);
|
||||
};
|
||||
|
@ -1,16 +1,19 @@
|
||||
import { useRecoilValue, useSetRecoilState } from 'recoil';
|
||||
|
||||
import { currentWorkspaceState } from '@/auth/states/currentWorkspaceState';
|
||||
import { useObjectMetadataItem } from '@/object-metadata/hooks/useObjectMetadataItem';
|
||||
import { useObjectNameSingularFromPlural } from '@/object-metadata/hooks/useObjectNameSingularFromPlural';
|
||||
import { turnFiltersIntoWhereClause } from '@/object-record/object-filter-dropdown/utils/turnFiltersIntoWhereClause';
|
||||
import { turnSortsIntoOrderBy } from '@/object-record/object-sort-dropdown/utils/turnSortsIntoOrderBy';
|
||||
import { useRecordTableScopedStates } from '@/object-record/record-table/hooks/internal/useRecordTableScopedStates';
|
||||
import { useRecordTable } from '@/object-record/record-table/hooks/useRecordTable';
|
||||
import { signInBackgroundMockCompanies } from '@/sign-in-background-mock/constants/signInBackgroundMockCompanies';
|
||||
|
||||
import { useFindManyRecords } from './useFindManyRecords';
|
||||
|
||||
export const useObjectRecordTable = () => {
|
||||
const { scopeId: objectNamePlural, setRecordTableData } = useRecordTable();
|
||||
const currentWorkspace = useRecoilValue(currentWorkspaceState);
|
||||
|
||||
const { objectNameSingular } = useObjectNameSingularFromPlural({
|
||||
objectNamePlural,
|
||||
@ -48,7 +51,7 @@ export const useObjectRecordTable = () => {
|
||||
});
|
||||
|
||||
return {
|
||||
records,
|
||||
records: currentWorkspace ? records : signInBackgroundMockCompanies,
|
||||
loading,
|
||||
fetchMoreRecords,
|
||||
queryStateIdentifier,
|
||||
|
@ -68,18 +68,22 @@ export const useRecordTableContextMenuEntries = (
|
||||
objectNameSingular,
|
||||
});
|
||||
|
||||
const handleDeleteClick = useRecoilCallback(({ snapshot }) => async () => {
|
||||
const rowIdsToDelete = snapshot
|
||||
.getLoadable(selectedRowIdsSelector)
|
||||
.getValue();
|
||||
const handleDeleteClick = useRecoilCallback(
|
||||
({ snapshot }) =>
|
||||
async () => {
|
||||
const rowIdsToDelete = snapshot
|
||||
.getLoadable(selectedRowIdsSelector)
|
||||
.getValue();
|
||||
|
||||
resetTableRowSelection();
|
||||
await Promise.all(
|
||||
rowIdsToDelete.map(async (rowId) => {
|
||||
await deleteOneRecord(rowId);
|
||||
}),
|
||||
);
|
||||
});
|
||||
resetTableRowSelection();
|
||||
await Promise.all(
|
||||
rowIdsToDelete.map(async (rowId) => {
|
||||
await deleteOneRecord(rowId);
|
||||
}),
|
||||
);
|
||||
},
|
||||
[deleteOneRecord, resetTableRowSelection],
|
||||
);
|
||||
|
||||
return {
|
||||
setContextMenuEntries: useCallback(() => {
|
||||
|
@ -20,7 +20,7 @@ export const RecordTableBody = () => {
|
||||
|
||||
return (
|
||||
<>
|
||||
{tableRowIds.slice().map((rowId, rowIndex) => (
|
||||
{tableRowIds.map((rowId, rowIndex) => (
|
||||
<RowIdContext.Provider value={rowId} key={rowId}>
|
||||
<RowIndexContext.Provider value={rowIndex}>
|
||||
<RecordTableRow key={rowId} rowId={rowId} />
|
||||
|
@ -1,14 +1,13 @@
|
||||
import { useRecoilCallback } from 'recoil';
|
||||
|
||||
import { entityFieldsFamilyState } from '@/object-record/field/states/entityFieldsFamilyState';
|
||||
import { useResetTableRowSelection } from '@/object-record/record-table/hooks/internal/useResetTableRowSelection';
|
||||
import { isFetchingRecordTableDataState } from '@/object-record/record-table/states/isFetchingRecordTableDataState';
|
||||
import { numberOfTableRowsState } from '@/object-record/record-table/states/numberOfTableRowsState';
|
||||
import { isDeeplyEqual } from '~/utils/isDeeplyEqual';
|
||||
|
||||
import { isFetchingRecordTableDataState } from '../../states/isFetchingRecordTableDataState';
|
||||
import { numberOfTableRowsState } from '../../states/numberOfTableRowsState';
|
||||
import { tableRowIdsState } from '../../states/tableRowIdsState';
|
||||
|
||||
import { useResetTableRowSelection } from './useResetTableRowSelection';
|
||||
|
||||
type useSetRecordTableDataProps = {
|
||||
onEntityCountChange: (entityCount: number) => void;
|
||||
};
|
||||
|
@ -5,7 +5,6 @@ import { useObjectNameSingularFromPlural } from '@/object-metadata/hooks/useObje
|
||||
import { useRecordTableContextMenuEntries } from '@/object-record/hooks/useRecordTableContextMenuEntries';
|
||||
import { useRecordTable } from '@/object-record/record-table/hooks/useRecordTable';
|
||||
import { filterAvailableTableColumns } from '@/object-record/utils/filterAvailableTableColumns';
|
||||
import { signInBackgroundMockCompanies } from '@/sign-in-background-mock/constants/signInBackgroundMockCompanies';
|
||||
import {
|
||||
signInBackgroundMockColumnDefinitions,
|
||||
signInBackgroundMockFilterDefinitions,
|
||||
@ -66,7 +65,6 @@ export const SignInBackgroundMockContainerEffect = ({
|
||||
);
|
||||
|
||||
setAvailableTableColumns(availableTableColumns);
|
||||
setRecordTableData(signInBackgroundMockCompanies);
|
||||
|
||||
setTableColumns(
|
||||
mapViewFieldsToColumnDefinitions(
|
||||
|
Loading…
Reference in New Issue
Block a user