From 4f7ae1ed8b6ecc2bee77d24b269b980031a0a7dc Mon Sep 17 00:00:00 2001 From: naoey Date: Thu, 17 Aug 2017 08:20:44 +0530 Subject: [PATCH] Clear messages when the current channel is removed. - Stop using TabContainer.Children --- osu.Game/Overlays/Chat/ChatTabControl.cs | 4 ++-- osu.Game/Overlays/ChatOverlay.cs | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/osu.Game/Overlays/Chat/ChatTabControl.cs b/osu.Game/Overlays/Chat/ChatTabControl.cs index ef4760d166..5f8db6fa71 100644 --- a/osu.Game/Overlays/Chat/ChatTabControl.cs +++ b/osu.Game/Overlays/Chat/ChatTabControl.cs @@ -82,12 +82,12 @@ namespace osu.Game.Overlays.Chat private void onTabClose(TabItem tab) { - int totalTabs = TabContainer.Children.Count - 1; // account for selectorTab + int totalTabs = TabContainer.Count - 1; // account for selectorTab int currentIndex = MathHelper.Clamp(TabContainer.IndexOf(tab), 1, totalTabs); if (tab == SelectedTab && totalTabs > 1) // Select the tab after tab-to-be-removed's index, or the tab before if current == last - SelectTab(TabContainer.Children[currentIndex == totalTabs ? currentIndex - 1 : currentIndex + 1]); + SelectTab(TabContainer[currentIndex == totalTabs ? currentIndex - 1 : currentIndex + 1]); else if (totalTabs == 1 && !selectorTab.Active) // Open channel selection overlay if all channel tabs will be closed after removing this tab SelectTab(selectorTab); diff --git a/osu.Game/Overlays/ChatOverlay.cs b/osu.Game/Overlays/ChatOverlay.cs index cc4177edc6..855fb5a1d6 100644 --- a/osu.Game/Overlays/ChatOverlay.cs +++ b/osu.Game/Overlays/ChatOverlay.cs @@ -397,7 +397,11 @@ namespace osu.Game.Overlays { if (channel == null) return; + if (channel == CurrentChannel) + currentChannelContainer.Clear(false); + careChannels.Remove(channel); + loadedChannels.Remove(loadedChannels.Find(c => c.Channel == channel)); channelTabs.RemoveItem(channel); channel.Joined.Value = false;