Skip to content

Commit 4851b43

Browse files
committed
fix: comparing devices event, needs to also compare the id
1 parent 68a50f3 commit 4851b43

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

SoundSwitch/Model/DeviceChangedEvent.cs

+6-2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ public record DeviceChangedEvent(EventType Action, string DeviceId) : IComparabl
1515
{
1616
public int CompareTo(DeviceChangedEvent other)
1717
{
18-
return Action.CompareTo(other.Action);
18+
if (ReferenceEquals(this, other)) return 0;
19+
if (ReferenceEquals(null, other)) return 1;
20+
var actionComparison = Action.CompareTo(other.Action);
21+
if (actionComparison != 0) return actionComparison;
22+
return string.Compare(DeviceId, other.DeviceId, StringComparison.Ordinal);
1923
}
20-
};
24+
}

0 commit comments

Comments
 (0)