1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-15 06:23:21 +08:00

Handle non-existing channels on message highlighting gracefully

This commit is contained in:
Salman Ahmed 2022-03-10 21:29:32 +03:00
parent c72e8a8b5e
commit 5315ff794a

View File

@ -309,10 +309,21 @@ namespace osu.Game.Overlays
/// <param name="message">The message to highlight.</param>
public void HighlightMessage(Message message)
{
if (channelManager.CurrentChannel.Value.Id != message.ChannelId)
channelManager.CurrentChannel.Value = channelManager.JoinedChannels.Single(c => c.Id == message.ChannelId);
Channel targetChannel;
channelManager.CurrentChannel.Value.HighlightedMessage.Value = message;
if (channelManager.CurrentChannel.Value.Id == message.ChannelId)
targetChannel = channelManager.CurrentChannel.Value;
else
{
targetChannel = channelManager.JoinedChannels.SingleOrDefault(c => c.Id == message.ChannelId);
if (targetChannel != null)
channelManager.CurrentChannel.Value = targetChannel;
else
targetChannel = channelManager.JoinChannel(channelManager.AvailableChannels.SingleOrDefault(c => c.Id == message.ChannelId), true);
}
targetChannel.HighlightedMessage.Value = message;
}
private float startDragChatHeight;