Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't show multiplayer channels in chat overlay #16109

Merged
merged 1 commit into from
Dec 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 19 additions & 0 deletions osu.Game.Tests/Visual/Online/TestSceneChatOverlay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,25 @@ public void TestChatCommand()
channelManager.CurrentChannel.Value.Type == ChannelType.PM && channelManager.CurrentChannel.Value.Users.Single().Username == "some body");
}

[Test]
public void TestMultiplayerChannelIsNotShown()
{
Channel multiplayerChannel = null;

AddStep("join multiplayer channel", () => channelManager.JoinChannel(multiplayerChannel = new Channel(new APIUser())
{
Name = "#mp_1",
Type = ChannelType.Multiplayer,
}));

AddAssert("channel joined", () => channelManager.JoinedChannels.Contains(multiplayerChannel));
AddAssert("channel not present in overlay", () => !chatOverlay.TabMap.ContainsKey(multiplayerChannel));
AddAssert("multiplayer channel is not current", () => channelManager.CurrentChannel.Value != multiplayerChannel);

AddStep("leave channel", () => channelManager.LeaveChannel(multiplayerChannel));
AddAssert("channel left", () => !channelManager.JoinedChannels.Contains(multiplayerChannel));
}

private void pressChannelHotkey(int number)
{
var channelKey = Key.Number0 + number;
Expand Down
14 changes: 9 additions & 5 deletions osu.Game/Overlays/ChatOverlay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -237,10 +237,7 @@ private void load(OsuConfigManager config, OsuColour colours, TextureStore textu
Schedule(() =>
{
// TODO: consider scheduling bindable callbacks to not perform when overlay is not present.
channelManager.JoinedChannels.CollectionChanged += joinedChannelsChanged;

foreach (Channel channel in channelManager.JoinedChannels)
ChannelTabControl.AddChannel(channel);
channelManager.JoinedChannels.BindCollectionChanged(joinedChannelsChanged, true);
Copy link
Contributor Author

@smoogipoo smoogipoo Dec 16, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's no special reason why this was this way. BindCollectionChanged was added after the event.


channelManager.AvailableChannels.CollectionChanged += availableChannelsChanged;
availableChannelsChanged(null, null);
Expand Down Expand Up @@ -436,12 +433,19 @@ private void joinedChannelsChanged(object sender, NotifyCollectionChangedEventAr
{
case NotifyCollectionChangedAction.Add:
foreach (Channel channel in args.NewItems.Cast<Channel>())
ChannelTabControl.AddChannel(channel);
{
if (channel.Type != ChannelType.Multiplayer)
Copy link
Sponsor Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we're gonna want to add spectator here at some point, but i guess that's not relevant until it's implemented.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't realise we had a spectator type, can be done later. Also, what's a temporary channel?

Copy link
Sponsor Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe it's an unused legacy type. Or maybe it is used but won't be relevant to lazer.

ChannelTabControl.AddChannel(channel);
}

break;

case NotifyCollectionChangedAction.Remove:
foreach (Channel channel in args.OldItems.Cast<Channel>())
{
if (!ChannelTabControl.Items.Contains(channel))
continue;

ChannelTabControl.RemoveChannel(channel);

var loaded = loadedChannels.Find(c => c.Channel == channel);
Expand Down