fix: error thrown when switching between table with/without record group (#9571)
Fix an error when switching between a table with and without record group.
This commit is contained in:
@ -1,16 +1,10 @@
|
|||||||
import { hasRecordGroupsComponentSelector } from '@/object-record/record-group/states/selectors/hasRecordGroupsComponentSelector';
|
|
||||||
import { recordIndexEntityCountByGroupComponentFamilyState } from '@/object-record/record-index/states/recordIndexEntityCountByGroupComponentFamilyState';
|
import { recordIndexEntityCountByGroupComponentFamilyState } from '@/object-record/record-index/states/recordIndexEntityCountByGroupComponentFamilyState';
|
||||||
import { recordIndexEntityCountNoGroupComponentFamilyState } from '@/object-record/record-index/states/recordIndexEntityCountNoGroupComponentFamilyState';
|
import { recordIndexEntityCountNoGroupComponentFamilyState } from '@/object-record/record-index/states/recordIndexEntityCountNoGroupComponentFamilyState';
|
||||||
import { useRecoilComponentCallbackStateV2 } from '@/ui/utilities/state/component-state/hooks/useRecoilComponentCallbackStateV2';
|
import { useRecoilComponentCallbackStateV2 } from '@/ui/utilities/state/component-state/hooks/useRecoilComponentCallbackStateV2';
|
||||||
import { useRecoilComponentValueV2 } from '@/ui/utilities/state/component-state/hooks/useRecoilComponentValueV2';
|
|
||||||
import { useRecoilCallback } from 'recoil';
|
import { useRecoilCallback } from 'recoil';
|
||||||
import { isDefined } from '~/utils/isDefined';
|
import { isDefined } from '~/utils/isDefined';
|
||||||
|
|
||||||
export const useSetRecordIndexEntityCount = (viewBarComponentId?: string) => {
|
export const useSetRecordIndexEntityCount = (viewBarComponentId?: string) => {
|
||||||
const hasRecordGroup = useRecoilComponentValueV2(
|
|
||||||
hasRecordGroupsComponentSelector,
|
|
||||||
);
|
|
||||||
|
|
||||||
const recordIndexEntityCountNoGroupFamilyState =
|
const recordIndexEntityCountNoGroupFamilyState =
|
||||||
useRecoilComponentCallbackStateV2(
|
useRecoilComponentCallbackStateV2(
|
||||||
recordIndexEntityCountNoGroupComponentFamilyState,
|
recordIndexEntityCountNoGroupComponentFamilyState,
|
||||||
@ -26,18 +20,13 @@ export const useSetRecordIndexEntityCount = (viewBarComponentId?: string) => {
|
|||||||
const setRecordIndexEntityCount = useRecoilCallback(
|
const setRecordIndexEntityCount = useRecoilCallback(
|
||||||
({ set }) =>
|
({ set }) =>
|
||||||
(count: number, recordGroupId?: string) => {
|
(count: number, recordGroupId?: string) => {
|
||||||
if (hasRecordGroup) {
|
if (isDefined(recordGroupId)) {
|
||||||
if (!isDefined(recordGroupId)) {
|
|
||||||
throw new Error('Record group ID is required');
|
|
||||||
}
|
|
||||||
|
|
||||||
set(recordIndexEntityCountByGroupFamilyState(recordGroupId), count);
|
set(recordIndexEntityCountByGroupFamilyState(recordGroupId), count);
|
||||||
} else {
|
} else {
|
||||||
set(recordIndexEntityCountNoGroupFamilyState, count);
|
set(recordIndexEntityCountNoGroupFamilyState, count);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[
|
[
|
||||||
hasRecordGroup,
|
|
||||||
recordIndexEntityCountByGroupFamilyState,
|
recordIndexEntityCountByGroupFamilyState,
|
||||||
recordIndexEntityCountNoGroupFamilyState,
|
recordIndexEntityCountNoGroupFamilyState,
|
||||||
],
|
],
|
||||||
|
|||||||
Reference in New Issue
Block a user