1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 03:22:57 +08:00

Make chat tests work again, clear old messages

This commit is contained in:
Dean Herbert 2018-11-17 10:40:44 +09:00
parent d09b674fb3
commit c1e3c4d435
2 changed files with 20 additions and 6 deletions

View File

@ -7,6 +7,7 @@ using osu.Framework.Graphics;
using osu.Game.Online.Chat;
using osu.Game.Tests.Visual;
using osu.Game.Tournament.Components;
using osu.Game.Tournament.IPC;
using osu.Game.Tournament.Screens.Ladder.Components;
using osu.Game.Users;
using OpenTK;
@ -39,6 +40,9 @@ namespace osu.Game.Tournament.Tests
[Cached]
private LadderInfo ladderInfo = new LadderInfo();
[Cached]
private MatchIPCInfo matchInfo = new MatchIPCInfo(); // hide parent
public TestCaseMatchChatDisplay()
{
MatchChatDisplay chatDisplay;

View File

@ -61,10 +61,6 @@ namespace osu.Game.Tournament.Components
{
if (ipc != null)
{
AddInternal(manager = new ChannelManager());
Channel.BindTo(manager.CurrentChannel);
chatChannel.BindTo(ipc.ChatChannel);
chatChannel.BindValueChanged(channelString =>
{
@ -73,7 +69,18 @@ namespace osu.Game.Tournament.Components
int id = int.Parse(channelString);
var channel = manager.JoinedChannels.FirstOrDefault(ch => ch.Id == id) ?? new Channel
if (id <= 0) return;
if (manager == null)
{
AddInternal(manager = new ChannelManager());
Channel.BindTo(manager.CurrentChannel);
}
foreach (var ch in manager.JoinedChannels.ToList())
manager.LeaveChannel(ch);
var channel = new Channel
{
Id = id,
Type = ChannelType.Public
@ -81,7 +88,6 @@ namespace osu.Game.Tournament.Components
manager.JoinChannel(channel);
manager.CurrentChannel.Value = channel;
}, true);
}
}
@ -92,6 +98,10 @@ namespace osu.Game.Tournament.Components
lastChannel.NewMessagesArrived -= newMessages;
lastChannel = channel;
messagesFlow.Clear();
if (channel == null) return;
channel.NewMessagesArrived += newMessages;
}