fix(ui): disposal guard on Alarm Summary live callback, matching the DebugView pattern (plan R2-07 T9)
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user