Fix update of aggregate operation not reflected in kanban header without refresh (#10879)

Before


https://github.com/user-attachments/assets/1761c49e-3d08-413a-bebd-11f4592a7de8

After


https://github.com/user-attachments/assets/064ef28f-b131-48af-ad66-11f782298670
This commit is contained in:
Weiko
2025-03-14 11:13:13 +01:00
committed by GitHub
parent 362bc333d1
commit 46c773e5ff
2 changed files with 13 additions and 16 deletions

View File

@ -1,15 +0,0 @@
import { AGGREGATE_OPERATIONS } from '@/object-record/record-table/constants/AggregateOperations';
import { createState } from '@ui/utilities/state/utils/createState';
type AggregateOperation = {
operation: AGGREGATE_OPERATIONS | null;
availableFieldIdsForOperation: string[];
};
export const aggregateDropdownState = createState<AggregateOperation>({
key: 'aggregateDropdownState',
defaultValue: {
operation: null,
availableFieldIdsForOperation: [],
},
});

View File

@ -1,15 +1,22 @@
import { contextStoreCurrentViewIdComponentState } from '@/context-store/states/contextStoreCurrentViewIdComponentState';
import { recordIndexKanbanAggregateOperationState } from '@/object-record/record-index/states/recordIndexKanbanAggregateOperationState';
import { ExtendedAggregateOperations } from '@/object-record/record-table/types/ExtendedAggregateOperations';
import { convertExtendedAggregateOperationToAggregateOperation } from '@/object-record/utils/convertExtendedAggregateOperationToAggregateOperation';
import { useRecoilComponentValueV2 } from '@/ui/utilities/state/component-state/hooks/useRecoilComponentValueV2';
import { useUpdateView } from '@/views/hooks/useUpdateView';
import { useCallback } from 'react';
import { useSetRecoilState } from 'recoil';
export const useUpdateViewAggregate = () => {
const currentViewId = useRecoilComponentValueV2(
contextStoreCurrentViewIdComponentState,
);
const { updateView } = useUpdateView();
const setRecordIndexKanbanAggregateOperationState = useSetRecoilState(
recordIndexKanbanAggregateOperationState,
);
const updateViewAggregate = useCallback(
({
kanbanAggregateOperationFieldMetadataId,
@ -27,8 +34,13 @@ export const useUpdateViewAggregate = () => {
kanbanAggregateOperationFieldMetadataId,
kanbanAggregateOperation: convertedKanbanAggregateOperation,
});
setRecordIndexKanbanAggregateOperationState({
operation: convertedKanbanAggregateOperation,
fieldMetadataId: kanbanAggregateOperationFieldMetadataId,
});
},
[currentViewId, updateView],
[currentViewId, updateView, setRecordIndexKanbanAggregateOperationState],
);
return {