Mass opening bug
This commit is contained in:
@@ -181,6 +181,7 @@
|
||||
{
|
||||
_stack.Clear();
|
||||
_stack.Add(BuildContext(Entity, ContentType));
|
||||
NormalizeStack();
|
||||
}
|
||||
else if (!string.Equals(_cacheFingerprint, latestFingerprint, StringComparison.Ordinal))
|
||||
{
|
||||
@@ -683,8 +684,17 @@
|
||||
|
||||
private async Task OpenEntityAsync(IInventoryEntity entity, ContentTypeName contentType)
|
||||
{
|
||||
var lastContext = _stack.LastOrDefault();
|
||||
if (lastContext is not null &&
|
||||
lastContext.ContentType == contentType &&
|
||||
lastContext.Entity.Id == entity.Id)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
await EnsureDependenciesLoadedAsync(entity, contentType);
|
||||
_stack.Add(BuildContext(entity, contentType));
|
||||
NormalizeStack();
|
||||
_cacheFingerprint = ComputeCacheFingerprint();
|
||||
await InvokeAsync(StateHasChanged);
|
||||
}
|
||||
@@ -707,6 +717,8 @@
|
||||
await EnsureDependenciesLoadedAsync(entity, contentType);
|
||||
_stack.Add(BuildContext(entity, contentType));
|
||||
}
|
||||
|
||||
NormalizeStack();
|
||||
}
|
||||
|
||||
private async Task EnsureDependenciesLoadedAsync(IInventoryEntity entity, ContentTypeName contentType)
|
||||
@@ -753,6 +765,34 @@
|
||||
.Select(pair => $"{pair.Key}:{pair.Value.Count}"));
|
||||
}
|
||||
|
||||
private void NormalizeStack()
|
||||
{
|
||||
if (_stack.Count <= 1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var seen = new HashSet<string>(StringComparer.Ordinal);
|
||||
var normalized = new List<InspectContext>(_stack.Count);
|
||||
|
||||
foreach (var context in _stack)
|
||||
{
|
||||
var key = $"{context.ContentType}:{context.Entity.Id}";
|
||||
if (seen.Add(key))
|
||||
{
|
||||
normalized.Add(context);
|
||||
}
|
||||
}
|
||||
|
||||
if (normalized.Count == _stack.Count)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_stack.Clear();
|
||||
_stack.AddRange(normalized);
|
||||
}
|
||||
|
||||
private static bool ValuesMatch(string propertyName, string? left, string? right)
|
||||
{
|
||||
if (string.Equals(propertyName, "HostType", StringComparison.OrdinalIgnoreCase))
|
||||
|
||||
Reference in New Issue
Block a user