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:
@@ -147,9 +147,9 @@ else
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
var user = await GetCurrentUserNameAsync();
|
var user = await GetCurrentUserNameAsync();
|
||||||
|
using var cts = new System.Threading.CancellationTokenSource(TimeSpan.FromSeconds(15));
|
||||||
var result = await AdminOps.AcknowledgeAlarmAsync(
|
var result = await AdminOps.AcknowledgeAlarmAsync(
|
||||||
alarmId, user, comment: null,
|
alarmId, user, comment: null, cts.Token);
|
||||||
new System.Threading.CancellationTokenSource(TimeSpan.FromSeconds(15)).Token);
|
|
||||||
ShowOpResult(alarmId, result.Ok, result.Ok ? "Ack sent" : (result.Message ?? "Failed"));
|
ShowOpResult(alarmId, result.Ok, result.Ok ? "Ack sent" : (result.Message ?? "Failed"));
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@@ -174,9 +174,9 @@ else
|
|||||||
// Timed shelve (with an unshelve-at datetime picker) is deferred — only OneShot + Unshelve
|
// 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
|
// are surfaced here, so unshelveAtUtc is always null. TimedShelve is fully wired through the
|
||||||
// singleton + AlarmCommand if a UI is added later.
|
// singleton + AlarmCommand if a UI is added later.
|
||||||
|
using var cts = new System.Threading.CancellationTokenSource(TimeSpan.FromSeconds(15));
|
||||||
var result = await AdminOps.ShelveAlarmAsync(
|
var result = await AdminOps.ShelveAlarmAsync(
|
||||||
alarmId, user, kind, unshelveAtUtc: null, comment: null,
|
alarmId, user, kind, unshelveAtUtc: null, comment: null, cts.Token);
|
||||||
new System.Threading.CancellationTokenSource(TimeSpan.FromSeconds(15)).Token);
|
|
||||||
var verb = kind == ShelveKind.Unshelve ? "Unshelve" : "Shelve";
|
var verb = kind == ShelveKind.Unshelve ? "Unshelve" : "Shelve";
|
||||||
ShowOpResult(alarmId, result.Ok, result.Ok ? $"{verb} sent" : (result.Message ?? "Failed"));
|
ShowOpResult(alarmId, result.Ok, result.Ok ? $"{verb} sent" : (result.Message ?? "Failed"));
|
||||||
}
|
}
|
||||||
@@ -209,6 +209,7 @@ else
|
|||||||
_opResultAlarmId = alarmId;
|
_opResultAlarmId = alarmId;
|
||||||
_opResultOk = ok;
|
_opResultOk = ok;
|
||||||
_opResultMessage = message;
|
_opResultMessage = message;
|
||||||
|
StateHasChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnAlarm(AlarmTransitionEvent evt) =>
|
private void OnAlarm(AlarmTransitionEvent evt) =>
|
||||||
|
|||||||
Reference in New Issue
Block a user