From 712bd21e2524b90bc253ee8fb3f1d6cb345f70fc Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 16 May 2017 18:25:03 +0900 Subject: [PATCH] Fix duplicate channels being created on connection loss Resolves #763 --- osu.Game/Overlays/ChatOverlay.cs | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/osu.Game/Overlays/ChatOverlay.cs b/osu.Game/Overlays/ChatOverlay.cs index e6dffbfe63..4748eb7de6 100644 --- a/osu.Game/Overlays/ChatOverlay.cs +++ b/osu.Game/Overlays/ChatOverlay.cs @@ -284,10 +284,21 @@ namespace osu.Game.Overlays { if (channel == null) return; - careChannels.Add(channel); - channelTabs.AddItem(channel); + var existing = careChannels.Find(c => c.Id == channel.Id); - // we need to get a good number of messages initially for each channel we care about. + if (existing != null) + { + // if we already have this channel loaded, we don't want to make a second one. + channel = existing; + } + else + { + + careChannels.Add(channel); + channelTabs.AddItem(channel); + } + + // let's fetch a small number of messages to bring us up-to-date with the backlog. fetchInitialMessages(channel); if (CurrentChannel == null)