diff --git a/src/MaxInventory.Web/Components/Pages/ContentTypePage.razor.cs b/src/MaxInventory.Web/Components/Pages/ContentTypePage.razor.cs index 6c52c49..2bcbf29 100644 --- a/src/MaxInventory.Web/Components/Pages/ContentTypePage.razor.cs +++ b/src/MaxInventory.Web/Components/Pages/ContentTypePage.razor.cs @@ -55,6 +55,7 @@ public partial class ContentTypePage : ComponentBase /// Populated on demand as relationships are requested. /// private readonly Dictionary> _dataCache = new(); + private readonly Dictionary _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); + } } /// @@ -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 } -} \ No newline at end of file +} diff --git a/src/MaxInventory.Web/Components/Shared/RelatedRecordsPanel.razor b/src/MaxInventory.Web/Components/Shared/RelatedRecordsPanel.razor index 3d2f134..5450f49 100644 --- a/src/MaxInventory.Web/Components/Shared/RelatedRecordsPanel.razor +++ b/src/MaxInventory.Web/Components/Shared/RelatedRecordsPanel.razor @@ -173,7 +173,6 @@ return; } - await EnsureDependenciesLoadedAsync(Entity, ContentType); var latestFingerprint = ComputeCacheFingerprint(); if (_stack.Count == 0 ||