1
0
mirror of https://github.com/ppy/osu.git synced 2026-05-13 20:33:35 +08:00

Avoid nuking logged in user's joined channels on showing match chat in tournament client

Closes https://github.com/ppy/osu/issues/35721.

I worry that straight up removing the nuke and not adding any channel
leave calls in exchange is going to leave tourney client users
with the *inverse* problem of being joined into a gorillion channels
from multiplayer matches they broadcasted, so this attempts to strike a
reasonable balance.
This commit is contained in:
Bartłomiej Dach
2025-11-19 11:23:58 +01:00
Unverified
parent ef4408a73e
commit 603c77e3e9
@@ -41,30 +41,33 @@ namespace osu.Game.Tournament.Components
chatChannel.BindTo(ipc.ChatChannel);
chatChannel.BindValueChanged(c =>
{
if (string.IsNullOrWhiteSpace(c.NewValue))
return;
int id = int.Parse(c.NewValue);
if (id <= 0) return;
if (manager == null)
{
AddInternal(manager = new ChannelManager(api));
Channel.BindTo(manager.CurrentChannel);
}
foreach (var ch in manager.JoinedChannels.ToList())
manager.LeaveChannel(ch);
var channel = new Channel
if (int.TryParse(c.OldValue, out int oldChannelId) && oldChannelId > 0)
{
Id = id,
Type = ChannelType.Public
};
var joinedChannel = manager.JoinedChannels.SingleOrDefault(ch => ch.Id == oldChannelId);
if (joinedChannel != null)
manager.LeaveChannel(joinedChannel);
}
manager.JoinChannel(channel);
manager.CurrentChannel.Value = channel;
if (string.IsNullOrWhiteSpace(c.NewValue))
return;
if (int.TryParse(c.NewValue, out int newChannelId) && newChannelId > 0)
{
var channel = new Channel
{
Id = newChannelId,
Type = ChannelType.Public
};
manager.JoinChannel(channel);
manager.CurrentChannel.Value = channel;
}
}, true);
}
}