Skip to content

Avoids unnecessary additional domain save notification publishing when sorting an already sorted collection of domains #19106

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

Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion src/Umbraco.Core/Services/DomainService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public IEnumerable<IDomain> GetAssignedDomains(int contentId, bool includeWildca
EventMessages eventMessages = EventMessagesFactory.Get();

IDomain[] domains = items.ToArray();
if (domains.Length == 0)
if (domains.Length == 0 || AreDomainsAlreadySorted(domains))
{
return OperationResult.Attempt.NoOperation(eventMessages);
}
Expand Down Expand Up @@ -144,4 +144,18 @@ public IEnumerable<IDomain> GetAssignedDomains(int contentId, bool includeWildca

return OperationResult.Attempt.Succeed(eventMessages);
}

private static bool AreDomainsAlreadySorted(IDomain[] domains)
{
// Check if the domains are already sorted by comparing the current sort order with what we'll set to be the new sort order.
for (int i = 0; i < domains.Length; i++)
{
if (domains[i].SortOrder != i)
{
return false;
}
}

return true;
}
}
Loading