Post #10014 merged nitpicks followup (#10021)

## Only nitpicks
Method signature mutation from several to one record arg
Renamed a variable in map to fit related business logic

#10014 Followup
This commit is contained in:
Paul Rastoin
2025-02-05 14:28:17 +01:00
committed by GitHub
parent 5c24cf4084
commit c3c800b097
5 changed files with 15 additions and 9 deletions

View File

@ -94,7 +94,7 @@ export const useHandleRecordGroupField = ({
);
if (viewGroupsToCreate.length > 0) {
await createViewGroupRecords(viewGroupsToCreate, view);
await createViewGroupRecords({ viewGroupsToCreate, viewId: view.id });
}
if (viewGroupsToDelete.length > 0) {

View File

@ -25,11 +25,11 @@ export const computeOptimisticRecordFromInput = ({
objectMetadataItems,
}: ComputeOptimisticCacheRecordInputArgs) => {
const unknownRecordInputFields = Object.keys(recordInput).filter(
(fieldName) => {
(recordKey) => {
const isUnknownMetadataItemField =
objectMetadataItem.fields.find(({ name }) => name === fieldName) ===
objectMetadataItem.fields.find((field) => field.name === recordKey) ===
undefined;
const isTypenameField = fieldName === OBJECT_RECORD_TYPENAME_KEY;
const isTypenameField = recordKey === OBJECT_RECORD_TYPENAME_KEY;
return isUnknownMetadataItemField && !isTypenameField;
},
);

View File

@ -4,10 +4,13 @@ import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSi
import { useCreateManyRecords } from '@/object-record/hooks/useCreateManyRecords';
import { useDestroyManyRecords } from '@/object-record/hooks/useDestroyManyRecords';
import { useUpdateOneRecordMutation } from '@/object-record/hooks/useUpdateOneRecordMutation';
import { GraphQLView } from '@/views/types/GraphQLView';
import { ViewGroup } from '@/views/types/ViewGroup';
import { useApolloClient } from '@apollo/client';
type CreateViewGroupRecordsArgs = {
viewGroupsToCreate: ViewGroup[];
viewId: string;
};
export const usePersistViewGroupRecords = () => {
const apolloClient = useApolloClient();
@ -25,13 +28,13 @@ export const usePersistViewGroupRecords = () => {
});
const createViewGroupRecords = useCallback(
(viewGroupsToCreate: ViewGroup[], view: GraphQLView) => {
({ viewGroupsToCreate, viewId }: CreateViewGroupRecordsArgs) => {
if (viewGroupsToCreate.length === 0) return;
return createManyRecords(
viewGroupsToCreate.map((viewGroup) => ({
...viewGroup,
viewId: view.id,
viewId,
})),
);
},

View File

@ -146,7 +146,10 @@ export const useCreateViewFromCurrentView = (viewBarComponentId?: string) => {
fieldMetadataId: kanbanFieldMetadataId,
} satisfies ViewGroup);
await createViewGroupRecords(viewGroupsToCreate, newView);
await createViewGroupRecords({
viewGroupsToCreate,
viewId: newView.id,
});
}
if (shouldCopyFiltersAndSortsAndAggregate === true) {

View File

@ -128,7 +128,7 @@ export const useSaveCurrentViewGroups = (viewBarComponentId?: string) => {
);
await Promise.all([
createViewGroupRecords(viewGroupsToCreate, view),
createViewGroupRecords({ viewGroupsToCreate, viewId: view.id }),
updateViewGroupRecords(viewGroupsToUpdate),
]);
},