Skip to content

NO-1221: Return original event for a single change in makeBulkChange - #399

Open
vivekjyani wants to merge 2 commits into
mainfrom
NO-1221
Open

vivekjyani wants to merge 2 commits into
mainfrom
NO-1221

Conversation

@vivekjyani

Copy link
Copy Markdown
Collaborator

Context

DocumentEditor.makeBulkChange(from:) consolidates a batch of per-row changelog events into a single v:2 bulk event (bulkRowUpdate / bulkRowDelete). Previously it required changes.count > 1 and returned nil for a single change, forcing callers to special-case the count-of-1 path. A single change needs no consolidation, so returning nil was surprising.

What changed

  • Sources/JoyfillUI/ViewModels/DocumentEditor+ChangeHandler.swift — makeBulkChange(from:): empty array still returns nil; a single change now returns that original event unchanged (v:1, original target); 2+ changes consolidate into a v:2 bulk event exactly as before.
  • JoyfillTests/.../DocumentEditor+ChangeHandlerTests.swift — the two single-change tests now assert the original event passes through (target unchanged, v == 1) instead of asserting nil.

Decisions

  • Pass the original Change through 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 needless bulk* target is emitted for a single row.
  • Empty-input behavior is intentionally left as 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 in DocumentEditorChangeHandlerTests).

Reviewer notes

Small, self-contained follow-up to the already-merged makeBulkChange feature. No behavioral change for the empty or 2+ paths.

@vivekjyani vivekjyani left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the single-change passthrough change. One contract question and two small cleanups below.

Comment thread Sources/JoyfillUI/ViewModels/DocumentEditor+ChangeHandler.swift Outdated
Comment thread Sources/JoyfillUI/ViewModels/DocumentEditor+ChangeHandler.swift Outdated

@VishnuBishnoi VishnuBishnoi left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants