Skip to content

Commit

Permalink
Merge pull request #260 from CodingDK/feature/prevent-duplicated-grid…
Browse files Browse the repository at this point in the history
…-blocks

Prevent adding blocks that already added to the grid blocks
  • Loading branch information
KevinJump authored Apr 20, 2024
2 parents 561946f + ef0d2ae commit c4562c7
Showing 1 changed file with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,17 @@ private Dictionary<string, Guid[]> AddGridContentBlocksToConfig(ILegacyGridEdito

_logger.LogDebug("Adding {editor} to block config for {count} blocks", editor.Alias, blocks.Count);

gridBlockContext.ContentBlocks.AddRange(blocks);
var containingBlockKeys = gridBlockContext.ContentBlocks.Select(x => x.ContentElementTypeKey).ToArray();

foreach (var block in blocks)
{
if (containingBlockKeys.Contains(block.ContentElementTypeKey))
{
_logger.LogDebug("Block ContentElementTypeKey {block} already exists in the config", block.ContentElementTypeKey);
continue;
}
gridBlockContext.ContentBlocks.Add(block);
}

allowedContentTypes[editor.Alias!] = blocks.Select(x => x.ContentElementTypeKey).ToArray();
}
Expand Down

0 comments on commit c4562c7

Please sign in to comment.