Skip to content

The editor's note lookup reads through its block lookup - #682

Merged
johnnyt merged 1 commit into
mainfrom
sb-n3ue-note-lookup-dedupe
Sep 30, 2026
Merged

johnnyt merged 1 commit into
mainfrom
sb-n3ue-note-lookup-dedupe

Conversation

@johnnyt

@johnnyt johnnyt commented Sep 30, 2026

Copy link
Copy Markdown
Member

What

block_note/2 in lib/statifier_blocks/editor.ex found its block with its own Enum.find(Document.blocks(document), &(&1.id == id)), the lookup block_by_id/2 in the same module already does. It now reads through block_by_id/2; the rest of the function is unchanged.

Behaviour is unchanged. Both callers of block_note/2, selected_note/2 and the "note-change" event handler, pass the socket's document, a %Document{}, which is what block_by_id/2 matches. For an id the document holds, the block's note is read as before (the empty string for a stored block with no :note key); for an id it no longer holds, nil as before. No public function changes what it answers.

Internal refactor: no changelog fragment (changelog.d/README.md excludes internal refactors).

Sabotage

Not a new test; a check that the existing note tests reach the note read on its new path. Mutation: block_note/2 answering the empty string for any found block. StatifierBlocks.Editor.NoteFieldTest went red on four tests, among them "the note textarea a change applies the command, and undo and redo move the note" (assertion). Reverted from a copy, byte-equal, recompiled.

Gate

Full mix quality green on the committed tree: 3,951 of 3,951 tests, 95.3% coverage, dialyzer clean, ADR cites green.

Review

In-turn review: re-read the diff against the bead. The acceptance asks that block_note/2 read through block_by_id/2, behaviour unchanged; the one-line change does that, and the two lookups were the same Enum.find over Document.blocks/1 by id. The separate block_by_id in lib/statifier_blocks/core/deadline_recipe.ex is a different module's private helper and is untouched.

Refs: sb-n3ue

block_note/2 in the editor found its block with its own
Enum.find over Document.blocks/1, the same lookup block_by_id/2 in the
module already does. It now reads through block_by_id/2. Every caller
passes the socket's document, which block_by_id/2's %Document{} match
accepts, so what the note reads is unchanged: the block's note, the
empty string for a stored block with no note key, nil for an id the
document no longer holds.

Internal refactor; no changelog fragment. Sabotaged: making the found
block's note read as empty turned four note field tests red.

Gate: full mix quality green on this staged tree (3,951 of 3,951
tests, 95.3% coverage, dialyzer clean, ADR cites green).

Refs: sb-n3ue
@johnnyt
johnnyt force-pushed the sb-n3ue-note-lookup-dedupe branch from 1e0c36c to c3560ce Compare September 30, 2026 11:18
@johnnyt
johnnyt merged commit 8346ba7 into main Sep 30, 2026
2 checks passed
@johnnyt
johnnyt deleted the sb-n3ue-note-lookup-dedupe branch September 30, 2026 11:20
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.

1 participant