Refactored object operation dispatch for SSE (#17174)

This PR refactors object record operation dispatch through a browser
event instead of a state that was registering all operations.

This is a cleaner pattern as it is a synchronous event code path instead
of relying on a useEffect to watch state change, which is not ideal.

We introduce this change first to then rely on this new pattern to
dispatch SSE events in a following PR.
This commit is contained in:
Lucas Bordeau
2026-01-15 17:38:21 +01:00
committed by GitHub
parent 3f28fde03a
commit 2cff75d772
31 changed files with 380 additions and 482 deletions
@@ -0,0 +1,12 @@
import { OBJECT_RECORD_OPERATION_BROWSER_EVENT_NAME } from '@/object-record/constants/ObjectRecordOperationBrowserEventName';
import { type ObjectRecordOperationBrowserEventDetail } from '@/object-record/types/ObjectRecordOperationBrowserEventDetail';
export const dispatchObjectRecordOperationBrowserEvent = (
detail: ObjectRecordOperationBrowserEventDetail,
) => {
window.dispatchEvent(
new CustomEvent(OBJECT_RECORD_OPERATION_BROWSER_EVENT_NAME, {
detail,
}),
);
};
@@ -0,0 +1,7 @@
export const getUpdatedFieldsFromRecordInput = (
recordInput: Record<string, unknown>,
): Record<string, unknown>[] => {
return Object.entries(recordInput)
.filter(([fieldName]) => fieldName !== 'id')
.map(([fieldName, fieldValue]) => ({ [fieldName]: fieldValue }));
};