Skip to content

Commit fc7de07

Browse files
committed
Prevented created of duplicate children
If the `ITopicMappingService` returns an existing obect (e.g., if the object is cached, or if the mapping service followed relationships) then adding children could result in duplicates. This is a _bit_ of a leaky abstraction since implementers shouldn't need to be aware of whether the `ITopicMappingService` is caching. That said, this is a bit of an edge case since typically the `ITopicMappingService` adds children, so the extra level of caution is warranted regardless.
1 parent 65680ef commit fc7de07

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

Ignia.Topics.Web.Mvc/Controllers/LayoutController.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ protected T AddNestedTopics(
189189
return null as T;
190190
}
191191
var viewModel = _topicMappingService.Map<T>(sourceTopic, Relationships.None);
192-
if (tiers >= 0 && (allowPageGroups || !sourceTopic.ContentType.Equals("PageGroup"))) {
192+
if (tiers >= 0 && (allowPageGroups || !sourceTopic.ContentType.Equals("PageGroup")) && viewModel.Children.Count == 0) {
193193
foreach (var topic in sourceTopic.Children.Sorted.Where(t => t.IsVisible())) {
194194
viewModel.Children.Add(
195195
AddNestedTopics(

0 commit comments

Comments
 (0)