Looooop fix
This commit is contained in:
@@ -55,6 +55,7 @@ public partial class ContentTypePage : ComponentBase
|
||||
/// Populated on demand as relationships are requested.
|
||||
/// </summary>
|
||||
private readonly Dictionary<ContentTypeName, IReadOnlyList<IInventoryEntity>> _dataCache = new();
|
||||
private readonly Dictionary<ContentTypeName, Task> _cacheLoadTasks = new();
|
||||
|
||||
// ── Lifecycle ────────────────────────────────────────────────────
|
||||
|
||||
@@ -127,10 +128,31 @@ public partial class ContentTypePage : ComponentBase
|
||||
{
|
||||
if (_dataCache.ContainsKey(contentType)) return;
|
||||
|
||||
var def = ContentTypeRegistry.GetDefinition(contentType);
|
||||
var items = await LoadEntitiesAsync(def);
|
||||
_dataCache[contentType] = items.AsReadOnly();
|
||||
StateHasChanged();
|
||||
if (_cacheLoadTasks.TryGetValue(contentType, out var existingLoad))
|
||||
{
|
||||
await existingLoad;
|
||||
return;
|
||||
}
|
||||
|
||||
async Task LoadAsync()
|
||||
{
|
||||
var def = ContentTypeRegistry.GetDefinition(contentType);
|
||||
var items = await LoadEntitiesAsync(def);
|
||||
_dataCache[contentType] = items.AsReadOnly();
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
var loadTask = LoadAsync();
|
||||
_cacheLoadTasks[contentType] = loadTask;
|
||||
|
||||
try
|
||||
{
|
||||
await loadTask;
|
||||
}
|
||||
finally
|
||||
{
|
||||
_cacheLoadTasks.Remove(contentType);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -195,7 +217,8 @@ public partial class ContentTypePage : ComponentBase
|
||||
await EnsureCachedAsync(ContentTypeName.Ips);
|
||||
|
||||
if (_definition.ContentType == ContentTypeName.Systems ||
|
||||
_definition.ContentType == ContentTypeName.Devices)
|
||||
_definition.ContentType == ContentTypeName.Devices ||
|
||||
_definition.ContentType == ContentTypeName.Vms)
|
||||
{
|
||||
await EnsureCachedAsync(ContentTypeName.Ips);
|
||||
await EnsureCachedAsync(ContentTypeName.Subnets);
|
||||
@@ -388,4 +411,4 @@ public partial class ContentTypePage : ComponentBase
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -173,7 +173,6 @@
|
||||
return;
|
||||
}
|
||||
|
||||
await EnsureDependenciesLoadedAsync(Entity, ContentType);
|
||||
var latestFingerprint = ComputeCacheFingerprint();
|
||||
|
||||
if (_stack.Count == 0 ||
|
||||
|
||||
Reference in New Issue
Block a user