fix(adminui): dispose Alerts CTS + self-render ShowOpResult (T21 review)

Dispose the CancellationTokenSource in AcknowledgeAsync and ShelveAsync
(the TimeSpan overload holds an internal timer — leaked without using).
Add StateHasChanged() to ShowOpResult so the result chip renders even if
a future caller omits the finally-block re-render.
This commit is contained in:
Joseph Doherty
2026-06-11 06:50:06 -04:00
parent 370a2b7b48
commit d860b0d8a6
@@ -147,9 +147,9 @@ else
try
{
var user = await GetCurrentUserNameAsync();
using var cts = new System.Threading.CancellationTokenSource(TimeSpan.FromSeconds(15));
var result = await AdminOps.AcknowledgeAlarmAsync(
alarmId, user, comment: null,
new System.Threading.CancellationTokenSource(TimeSpan.FromSeconds(15)).Token);
alarmId, user, comment: null, cts.Token);
ShowOpResult(alarmId, result.Ok, result.Ok ? "Ack sent" : (result.Message ?? "Failed"));
}
catch (Exception ex)
@@ -174,9 +174,9 @@ else
// Timed shelve (with an unshelve-at datetime picker) is deferred — only OneShot + Unshelve
// are surfaced here, so unshelveAtUtc is always null. TimedShelve is fully wired through the
// singleton + AlarmCommand if a UI is added later.
using var cts = new System.Threading.CancellationTokenSource(TimeSpan.FromSeconds(15));
var result = await AdminOps.ShelveAlarmAsync(
alarmId, user, kind, unshelveAtUtc: null, comment: null,
new System.Threading.CancellationTokenSource(TimeSpan.FromSeconds(15)).Token);
alarmId, user, kind, unshelveAtUtc: null, comment: null, cts.Token);
var verb = kind == ShelveKind.Unshelve ? "Unshelve" : "Shelve";
ShowOpResult(alarmId, result.Ok, result.Ok ? $"{verb} sent" : (result.Message ?? "Failed"));
}
@@ -209,6 +209,7 @@ else
_opResultAlarmId = alarmId;
_opResultOk = ok;
_opResultMessage = message;
StateHasChanged();
}
private void OnAlarm(AlarmTransitionEvent evt) =>