fix(centralui): pass siteId+connectionName into ShowAsync explicitly

Razor parameter binding propagates on the next render, so reading SiteId
inside LoadRootAsync raced against the parent's "set field, then call
ShowAsync()" pattern — central received an empty siteId and rejected
with "No ClusterClient for site ,". Take the values as args instead.
This commit is contained in:
Joseph Doherty
2026-05-28 12:40:35 -04:00
parent c1e16cf9ff
commit 2c138b6a25
2 changed files with 13 additions and 6 deletions
@@ -96,11 +96,18 @@
public bool Truncated { get; set; } public bool Truncated { get; set; }
} }
public async Task ShowAsync() private string _runtimeSiteId = "";
private string _runtimeConnectionName = "";
public async Task ShowAsync(string siteId, string connectionName, string? initialNodeId)
{ {
// Snapshot at click time. Razor parameter binding propagates on the next
// render, which would race the immediate LoadRootAsync below.
_runtimeSiteId = siteId;
_runtimeConnectionName = connectionName;
_isVisible = true; _isVisible = true;
_manualNodeId = InitialNodeId ?? ""; _manualNodeId = initialNodeId ?? "";
_selectedNodeId = InitialNodeId; _selectedNodeId = initialNodeId;
await LoadRootAsync(); await LoadRootAsync();
} }
@@ -110,7 +117,7 @@
_rootNodes = new(); _rootNodes = new();
StateHasChanged(); StateHasChanged();
var result = await BrowseService.BrowseChildrenAsync(SiteId, ConnectionName, parentNodeId: null); var result = await BrowseService.BrowseChildrenAsync(_runtimeSiteId, _runtimeConnectionName, parentNodeId: null);
if (result.Failure is not null) if (result.Failure is not null)
{ {
SetFailure(result.Failure); SetFailure(result.Failure);
@@ -135,7 +142,7 @@
{ {
node.Loading = true; node.Loading = true;
StateHasChanged(); StateHasChanged();
var result = await BrowseService.BrowseChildrenAsync(SiteId, ConnectionName, node.NodeId); var result = await BrowseService.BrowseChildrenAsync(_runtimeSiteId, _runtimeConnectionName, node.NodeId);
node.Loading = false; node.Loading = false;
if (result.Failure is not null) if (result.Failure is not null)
@@ -573,7 +573,7 @@
?? GetTemplateDefault(attrName); ?? GetTemplateDefault(attrName);
if (_browserRef is not null) if (_browserRef is not null)
await _browserRef.ShowAsync(); await _browserRef.ShowAsync(_siteIdentifier, conn.Name, _browserInitial);
} }
private void OnBrowserSelected(string nodeId) private void OnBrowserSelected(string nodeId)