fix(ui): disposal guard on Alarm Summary live callback, matching the DebugView pattern (plan R2-07 T9)

This commit is contained in:
Joseph Doherty
2026-07-13 10:58:50 -04:00
parent 925c869826
commit 76ef97f729
2 changed files with 32 additions and 1 deletions
@@ -382,15 +382,20 @@
_liveSubscription = null;
}
// N7: set BEFORE teardown so a live callback racing Dispose is dropped both
// before the InvokeAsync marshal and inside it (mirrors DebugView.razor).
private volatile bool _disposed;
// Raised on the aggregator's thread — marshal onto the circuit before touching state.
private void OnLiveAlarmsChanged(int siteId)
{
if (_disposed) return;
_ = InvokeAsync(() =>
{
// Drop stale callbacks for a site we've since navigated away from, and
// let the poll drive until the aggregator has actually seeded (so we never
// clobber a good poll snapshot with an empty pre-seed list).
if (_selectedSiteId != siteId || !LiveAlarmCache.IsLive(siteId))
if (_disposed || _selectedSiteId != siteId || !LiveAlarmCache.IsLive(siteId))
{
return;
}
@@ -525,6 +530,7 @@
public void Dispose()
{
_disposed = true;
StopTimer();
DisposeLiveSubscription();
}