Skip to content

Commit

Permalink
DataList - UmbracoContent, UmbracoContext refactor
Browse files Browse the repository at this point in the history
Small tweak to save calling `_umbracoContextAccessor.GetRequiredUmbracoContext()` twice.
leekelleher committed Sep 8, 2021
1 parent 91c1f75 commit b57bf92
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -65,11 +65,11 @@ public IEnumerable<DataListItem> GetItems(Dictionary<string, object> config)
var preview = true;
var parentNode = config.GetValueAs("parentNode", string.Empty);
var startNode = default(IPublishedContent);
var umbracoContext = _umbracoContextAccessor.GetRequiredUmbracoContext();

if (parentNode.InvariantStartsWith("umb://document/") == false)
{
var nodeContextId = default(int?);
var umbracoContext = _umbracoContextAccessor.GetRequiredUmbracoContext();

// NOTE: First we check for "id" (if on a content page), then "parentId" (if editing an element).
if (int.TryParse(_requestAccessor.GetQueryStringValue("id"), out var currentId) == true)
@@ -98,7 +98,7 @@ public IEnumerable<DataListItem> GetItems(Dictionary<string, object> config)
}
else if (UdiParser.TryParse(parentNode, out GuidUdi udi) == true && udi.Guid != Guid.Empty)
{
startNode = _umbracoContextAccessor.GetRequiredUmbracoContext().Content.GetById(preview, udi.Guid);
startNode = umbracoContext.Content.GetById(preview, udi.Guid);
}

if (startNode != null)

0 comments on commit b57bf92

Please sign in to comment.