review(Client.UI): single notification when removing non-retained alarm row
Re-review at 7286d320. -013: AlarmsViewModel.OnAlarmEvent removal path no longer fires a
redundant Replace+Remove (one Remove now), preventing a DataGrid re-paint flash. -012: add
update/remove-path test coverage. + TDD.
This commit is contained in:
@@ -71,14 +71,21 @@ public partial class AlarmsViewModel : ObservableObject
|
||||
if (existing != null)
|
||||
{
|
||||
var index = AlarmEvents.IndexOf(existing);
|
||||
AlarmEvents[index] = new AlarmEventViewModel(
|
||||
e.SourceName, e.ConditionName, e.Severity, e.Message,
|
||||
e.Retain, e.ActiveState, e.AckedState, e.Time,
|
||||
e.EventId, e.ConditionNodeId);
|
||||
|
||||
// Remove alarms that are no longer retained
|
||||
if (!e.Retain)
|
||||
{
|
||||
// Alarm is no longer retained — remove it with a single collection mutation
|
||||
// rather than Replace + Remove (which would fire two change notifications).
|
||||
AlarmEvents.RemoveAt(index);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Alarm is still retained — update the row in place.
|
||||
AlarmEvents[index] = new AlarmEventViewModel(
|
||||
e.SourceName, e.ConditionName, e.Severity, e.Message,
|
||||
e.Retain, e.ActiveState, e.AckedState, e.Time,
|
||||
e.EventId, e.ConditionNodeId);
|
||||
}
|
||||
}
|
||||
else if (e.Retain)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user