mirror of https://github.com/ppy/osu
Use separate method for fetching channel objects
Resolves a pull request review
This commit is contained in:
parent
39c3b08fc7
commit
ce4bcda803
|
@ -76,9 +76,18 @@ private void newMessagesArrived(IEnumerable<Message> messages)
|
|||
HandleMessages(messages.First().ChannelId, messages);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Searches for a channel with the matching <paramref name="channelId"/>, returns <see langword="null"/> when none found.
|
||||
/// </summary>
|
||||
private Channel fetchJoinedChannel(long channelId)
|
||||
{
|
||||
return channelManager.JoinedChannels.SingleOrDefault(c => c.Id == channelId);
|
||||
}
|
||||
|
||||
public void HandleMessages(long channelId, IEnumerable<Message> messages)
|
||||
{
|
||||
var channel = channelManager.JoinedChannels.SingleOrDefault(c => c.Id == channelId);
|
||||
// Fetch channel object
|
||||
var channel = fetchJoinedChannel(channelId);
|
||||
|
||||
if (channel == null)
|
||||
{
|
||||
|
@ -86,11 +95,6 @@ public void HandleMessages(long channelId, IEnumerable<Message> messages)
|
|||
return;
|
||||
}
|
||||
|
||||
HandleMessages(channel, messages);
|
||||
}
|
||||
|
||||
public void HandleMessages(Channel channel, IEnumerable<Message> messages)
|
||||
{
|
||||
// Only send notifications, if ChatOverlay and the target channel aren't visible.
|
||||
if (chatOverlay?.IsPresent == true && channelManager.CurrentChannel.Value == channel)
|
||||
return;
|
||||
|
|
Loading…
Reference in New Issue