From 78c1d4581f84978a2db96e78807edaac2b417456 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 17 May 2017 13:44:43 +0900 Subject: [PATCH] Revert "Use generic IComparable for message." This reverts commit aaaee5ed102e54a2fe40209e0ebe967015b29b83. --- osu.Game/Online/Chat/Channel.cs | 2 +- osu.Game/Online/Chat/Message.cs | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/osu.Game/Online/Chat/Channel.cs b/osu.Game/Online/Chat/Channel.cs index 93fd0a8956..2925c3ccb4 100644 --- a/osu.Game/Online/Chat/Channel.cs +++ b/osu.Game/Online/Chat/Channel.cs @@ -23,7 +23,7 @@ public class Channel [JsonProperty(@"channel_id")] public int Id; - public readonly SortedList Messages = new SortedList(Comparer.Default); + public readonly SortedList Messages = new SortedList((m1, m2) => m1.Id.CompareTo(m2.Id)); //internal bool Joined; diff --git a/osu.Game/Online/Chat/Message.cs b/osu.Game/Online/Chat/Message.cs index c1887e7824..bf53a68910 100644 --- a/osu.Game/Online/Chat/Message.cs +++ b/osu.Game/Online/Chat/Message.cs @@ -8,7 +8,7 @@ namespace osu.Game.Online.Chat { - public class Message : IComparable + public class Message { [JsonProperty(@"message_id")] public readonly long Id; @@ -42,7 +42,17 @@ public Message(long id) Id = id; } - public int CompareTo(Message other) => Id.CompareTo(other.Id); + public override bool Equals(object obj) + { + var objMessage = obj as Message; + + return Id == objMessage?.Id; + } + + public override int GetHashCode() + { + return Id.GetHashCode(); + } } public enum TargetType