Repository navigation
NO-1221: Return original event for a single change in makeBulkChange - #399
vivekjyani wants to merge 2 commits into
Conversation
vivekjyani
left a comment
There was a problem hiding this comment.
Reviewed the single-change passthrough change. One contract question and two small cleanups below.
VishnuBishnoi
left a comment
There was a problem hiding this comment.
Reviewed at eaab942 against 616d3d6.
No blocking findings. The target guard now runs before singleton passthrough, so only rowUpdate/rowDelete are returned unchanged. The full original Change is preserved, and the 2+ item validation/consolidation paths are unchanged. The documentation matches this behavior.
Exact-head build and unit CI passed: 2,334 tests, zero failures. UI tests were skipped; this change is confined to the event helper. No local tests were run.
Non-blocking test improvement: assert full singleton dictionary equality, including nested routing and extra metadata, rather than only target/version.
Context
DocumentEditor.makeBulkChange(from:)consolidates a batch of per-row changelog events into a singlev:2bulk event (bulkRowUpdate/bulkRowDelete). Previously it requiredchanges.count > 1and returnednilfor a single change, forcing callers to special-case the count-of-1 path. A single change needs no consolidation, so returningnilwas surprising.What changed
Sources/JoyfillUI/ViewModels/DocumentEditor+ChangeHandler.swift—makeBulkChange(from:): empty array still returnsnil; a single change now returns that original event unchanged (v:1, original target); 2+ changes consolidate into av:2bulk event exactly as before.JoyfillTests/.../DocumentEditor+ChangeHandlerTests.swift— the two single-change tests now assert the original event passes through (targetunchanged,v == 1) instead of assertingnil.Decisions
Changethrough as-is rather than wrapping one change in a bulk envelope — the consumer gets the plain event it already knows how to handle, and no needlessbulk*target is emitted for a single row.nil(nothing to send).Screenshot / video
N/A — logic-only change, no UI.
Public API
makeBulkChange(from:)is public; the signature is unchanged. Only the single-change return value changes (nil→ original event). Minor doc note: the method's doc comment still reads "Returns nil unless it's a multi-row…"; worth a one-line update when touched next.Tests
Covered. Single-change update/delete passthrough is asserted; empty-array
nil, multi-row consolidation, and all existing guards remain green (132/132 inDocumentEditorChangeHandlerTests).Reviewer notes
Small, self-contained follow-up to the already-merged
makeBulkChangefeature. No behavioral change for the empty or 2+ paths.