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