1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-27 14:12:56 +08:00

Fix clicking "+" tab showing an empty channel in some cases (#4759)

Fix clicking "+" tab showing an empty channel in some cases

Co-authored-by: Dean Herbert <pe@ppy.sh>
This commit is contained in:
Dean Herbert 2019-05-12 21:14:45 +09:00 committed by GitHub
commit 50c4e788af
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 22 additions and 6 deletions

View File

@ -93,7 +93,7 @@ namespace osu.Game.Tests.Visual.Online
AddUntilStep("remove all channels", () => AddUntilStep("remove all channels", () =>
{ {
var first = channelTabControl.Items.First(); var first = channelTabControl.Items.First();
if (first.Name == "+") if (first is ChannelSelectorTabItem.ChannelSelectorTabChannel)
return true; return true;
channelTabControl.RemoveChannel(first); channelTabControl.RemoveChannel(first);

View File

@ -10,6 +10,7 @@ using osu.Framework.Bindables;
using osu.Framework.Logging; using osu.Framework.Logging;
using osu.Game.Online.API; using osu.Game.Online.API;
using osu.Game.Online.API.Requests; using osu.Game.Online.API.Requests;
using osu.Game.Overlays.Chat.Tabs;
using osu.Game.Users; using osu.Game.Users;
namespace osu.Game.Online.Chat namespace osu.Game.Online.Chat
@ -84,7 +85,11 @@ namespace osu.Game.Online.Chat
?? new Channel(user); ?? new Channel(user);
} }
private void currentChannelChanged(ValueChangedEvent<Channel> e) => JoinChannel(e.NewValue); private void currentChannelChanged(ValueChangedEvent<Channel> e)
{
if (!(e.NewValue is ChannelSelectorTabItem.ChannelSelectorTabChannel))
JoinChannel(e.NewValue);
}
/// <summary> /// <summary>
/// Ensure we run post actions in sequence, once at a time. /// Ensure we run post actions in sequence, once at a time.

View File

@ -13,8 +13,8 @@ namespace osu.Game.Overlays.Chat.Tabs
public override bool IsSwitchable => false; public override bool IsSwitchable => false;
public ChannelSelectorTabItem(Channel value) public ChannelSelectorTabItem()
: base(value) : base(new ChannelSelectorTabChannel())
{ {
Depth = float.MaxValue; Depth = float.MaxValue;
Width = 45; Width = 45;
@ -31,5 +31,13 @@ namespace osu.Game.Overlays.Chat.Tabs
BackgroundInactive = colour.Gray2; BackgroundInactive = colour.Gray2;
BackgroundActive = colour.Gray3; BackgroundActive = colour.Gray3;
} }
public class ChannelSelectorTabChannel : Channel
{
public ChannelSelectorTabChannel()
{
Name = "+";
}
}
} }
} }

View File

@ -38,7 +38,7 @@ namespace osu.Game.Overlays.Chat.Tabs
Margin = new MarginPadding(10), Margin = new MarginPadding(10),
}); });
AddTabItem(selectorTab = new ChannelSelectorTabItem(new Channel { Name = "+" })); AddTabItem(selectorTab = new ChannelSelectorTabItem());
ChannelSelectorActive.BindTo(selectorTab.Active); ChannelSelectorActive.BindTo(selectorTab.Active);
} }

View File

@ -199,6 +199,9 @@ namespace osu.Game.Overlays
return; return;
} }
if (e.NewValue is ChannelSelectorTabItem.ChannelSelectorTabChannel)
return;
textbox.Current.Disabled = e.NewValue.ReadOnly; textbox.Current.Disabled = e.NewValue.ReadOnly;
if (channelTabControl.Current.Value != e.NewValue) if (channelTabControl.Current.Value != e.NewValue)
@ -268,7 +271,7 @@ namespace osu.Game.Overlays
private void selectTab(int index) private void selectTab(int index)
{ {
var channel = channelTabControl.Items.Skip(index).FirstOrDefault(); var channel = channelTabControl.Items.Skip(index).FirstOrDefault();
if (channel != null && channel.Name != "+") if (channel != null && !(channel is ChannelSelectorTabItem.ChannelSelectorTabChannel))
channelTabControl.Current.Value = channel; channelTabControl.Current.Value = channel;
} }