Fix: Shared Blocks: State memory leak, each time inserter is opened new blocks are added #8153
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Each time the inserter was opened the shared blocks were requested and new blocks to represent them (used in their preview) were inserted.
Description
This PR adds a flag to all blocks that are inserted as part of the share blocks mechanism ( are not part of the document). This flag is useful to know each blocks are part of the document and which blocks are not part of the document.
When inserting new shared blocks we remove the previous blocks that contained that flag (we remove the previous share blocks).
How has this been tested?
Make sure you have some shared blocks (if not create some blocks before).
Write a post.
Add a block and write something.
Press the inserter.
Press the information icon and view the block count (it is high because all share blocks are counted even if they were not inserted in the document).
Press the inserter again.
View the block count again and verify it stayed the same (in master each time we open the inserter and check the block count the number increased).