-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Refactor comments #2502
base: develop
Are you sure you want to change the base?
Refactor comments #2502
Conversation
This works similar to the blocks attribute.
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.
Thanks for the fixes! I made a couple of suggestions (and I think @adroitwhiz's suggestions are pretty good too!). Also I think we should reconsider the call signatures of deserializeInputDesc
and deserializeBlocks
to make it easier to understand what they're doing. For example, I think we can avoid a lot of the complication in comment attachment fixup for deserialized primitives by reusing the existing ID instead of mapping old ID to new ID. I want to talk to some others on the Scratch team and maybe we'll have more suggestions after that.
If you split the fix for #1893 into a separate PR then we can probably take the rest of the fixes while we're still debating the details of the deserialized primitive block IDs and such. |
I'm doing that @cwillisf |
882ed8b
to
0f211b7
Compare
Resolves
Resolves scratchfoundation/scratch-gui#3687
Resolves #2501
note: #1893 will no longer be resolved
Proposed Changes
First commits move comment attribute to
Sprite
, similar toblocks
attribute. This was necessary to fix gui#3687. It also changes newBlockId so that it returns the mapping; the mapping is used insideSprite.duplicate
to fix gui#3687. RenderedTarget and Target still has comments attribute, so it should not cause problems.Second commit is to fix #2501 - comments attached to blocks will now be deleted if the block is deleted, by deleting the comment item in
deleteBlock
.Third commit is for #1893 . It has one breaking change;
deserializeBlocks
now return{blocks, oldToNew}
instead ofblocks
. The mapping is used to syncComment.blockId
andblock.comment
later, inparseScratchObject
. It also checks if the block actually exists - so any project that was saved with "invisible comment" (by #2501) will lose them.Fourth commit is mostly tests. One new integration test is added to test #1893 and two unit tests are added to
engine_blocks
andsprites_rendered-targets
to test #2501 and gui#3687, and they all pass for me.Reason for Changes
Sprite
: first, it does not make sense that a Target - which includes clones - is controlling the sprite-wide comments. This also fixes consistency between blocks and comments. The major reason is, though, we needed to handle duplication insideSprite.duplicate
, notRenderedTarget.duplicte
- because we needed the mapping. I could usethis.clones[0]
but it will make messy code.newBlockIds
return value - it was necessary to implement duplicating comments attached to blocksTest Coverage
Added 1 integration test (variable-comment) and 2 unit tests (see above).
Manual testing: