-
Notifications
You must be signed in to change notification settings - Fork 57
Inserter - added direct insertion to block manager (take2) #110
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Inserter - added direct insertion to block manager (take2) #110
Conversation
…ts BlockActionType
|
|
||
| // TODO: block type picker here instead of hardcoding a core/code block | ||
| const newBlock = createBlock( 'core/paragraph', { content: 'new test text for a core/paragraph block' } ); | ||
| const newBlockWithFocusedState = { ...newBlock, focused: false }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know it's not part of the PR's diff but, wdyt about doing a small optimization here by just appending to the object a new field instead of creating a full new object?
We can just do:
newBlock.focused = false;
and use the newBlock instead of construct the newBlockWithFocusedState.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| it( 'should create an action to create a block', () => { | ||
| const newBlock = createBlock( 'core/code', { content: 'new test text for a core/code block' } ); | ||
| const action = actions.createBlockAction( '1', newBlock ); | ||
| const action = actions.createBlockAction( '1', newBlock, '0' ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's also test the clientIdAbove while at it, wdyt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
addressed in 8814dc0
src/store/reducers/index.js
Outdated
| // TODO we need to set focused: true and search for the currently focused block and | ||
| // set that one to `focused: false`. | ||
| blocks.push(action.block); | ||
| insertBlock(blocks, action.block, action.clientIdAbove); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, should this insertBlock replace the blocks.push in the previous line?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ooops thank Lord you catched that, addressed c1b51b9
src/store/reducers/index.js
Outdated
| // TODO we need to set focused: true and search for the currently focused block and | ||
| // set that one to `focused: false`. | ||
| const insertionIndex = findBlockIndex( blocks, clientIdAbove ); | ||
| if (insertionIndex === blocks.length - 1) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we really need the check? If it's just for guarding against the end of the array, I think splice takes care of that already so we don't need to. See here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TIL! addressed in 145e82f
|
Nice one @mzorz ! I left a few comments, have a look and let me know if something is not clear! Thanks! |
|
Ready for another round @hypest - thank you! 🙇 |
|
flow has given its OK now with the new |
hypest
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice flow fix @mzorz!
LGTM!
…oid-to-v1.3.14 Bump Aztec Android to v1.3.14
Closing #96 in favor of this one, as the base branch of #95 is not needed anymore, and avoid messing with commit history
Adds direct insertion at a specific index in the list state. For the sake of the exercise in the GB mobile application for now we're inserting right below the tapped block.
Before, it would only append new blocks to the list.
Android
iOS