fix(client-ui): resolve Medium code-review finding (Client.UI-005)
Call Subscriptions?.Teardown() and Alarms?.Teardown() in the Disconnected branch of OnConnectionStateChanged so server-side session drops also quiesce the DataChanged and AlarmEvent handlers. Add Reattach() methods that idempotently re-hook the handlers; call them from the Connected branch so reconnects after a server-side drop restore live updates. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -265,6 +265,16 @@ public partial class SubscriptionsViewModel : ObservableObject
|
||||
SubscriptionCount = 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Re-hooks event handlers to the service after a server-side reconnect.
|
||||
/// Safe to call when already attached (duplicate += is a no-op in .NET multicast delegates).
|
||||
/// </summary>
|
||||
public void Reattach()
|
||||
{
|
||||
_service.DataChanged -= OnDataChanged;
|
||||
_service.DataChanged += OnDataChanged;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Unhooks event handlers from the service.
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user