Removed value setter effect completely (#12101)

This PR removes the effect component that was synchronizing the record
store recoil state with the context selector equivalent state that is
used for performance on the tables.

Now we only set the context selector in parallel with the recoil state,
thus avoiding any synchronization side-effect between those two states.
This commit is contained in:
Lucas Bordeau
2025-05-17 15:41:01 +02:00
committed by GitHub
parent 64d988cdec
commit 58b40b1f89
10 changed files with 34 additions and 54 deletions

View File

@ -4,8 +4,10 @@ import { FIND_ONE_CALENDAR_EVENT_OPERATION_SIGNATURE } from '@/activities/calend
import { CalendarEvent } from '@/activities/calendar/types/CalendarEvent';
import { viewableRecordIdComponentState } from '@/command-menu/pages/record-page/states/viewableRecordIdComponentState';
import { useFindOneRecord } from '@/object-record/hooks/useFindOneRecord';
import { RecordValueSetterEffect } from '@/object-record/record-store/components/RecordValueSetterEffect';
import { RecordFieldValueSelectorContextProvider } from '@/object-record/record-store/contexts/RecordFieldValueSelectorContext';
import {
RecordFieldValueSelectorContextProvider,
useSetRecordValue,
} from '@/object-record/record-store/contexts/RecordFieldValueSelectorContext';
import { useUpsertRecordsInStore } from '@/object-record/record-store/hooks/useUpsertRecordsInStore';
import { useRecoilComponentValueV2 } from '@/ui/utilities/state/component-state/hooks/useRecoilComponentValueV2';
@ -14,13 +16,18 @@ export const CommandMenuCalendarEventPage = () => {
const viewableRecordId = useRecoilComponentValueV2(
viewableRecordIdComponentState,
);
const setRecordValueInContextSelector = useSetRecordValue();
const { record: calendarEvent } = useFindOneRecord<CalendarEvent>({
objectNameSingular:
FIND_ONE_CALENDAR_EVENT_OPERATION_SIGNATURE.objectNameSingular,
objectRecordId: viewableRecordId ?? '',
recordGqlFields: FIND_ONE_CALENDAR_EVENT_OPERATION_SIGNATURE.fields,
onCompleted: (record) => upsertRecords([record]),
// TODO: this is not executed on sub-sequent runs, make sure that it is intended
onCompleted: (record) => {
upsertRecords([record]);
setRecordValueInContextSelector(record.id, record);
},
});
if (!calendarEvent) {
@ -30,7 +37,6 @@ export const CommandMenuCalendarEventPage = () => {
return (
<RecordFieldValueSelectorContextProvider>
<CalendarEventDetailsEffect record={calendarEvent} />
<RecordValueSetterEffect recordId={calendarEvent.id} />
<CalendarEventDetails calendarEvent={calendarEvent} />
</RecordFieldValueSelectorContextProvider>
);