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:
Joseph Doherty
2026-05-22 07:27:03 -04:00
parent af454c6af6
commit a9cede8ed4
3 changed files with 24 additions and 0 deletions

View File

@@ -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>