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

Add constructor to create a PM channel from a User

This commit is contained in:
Dean Herbert 2018-12-07 13:56:21 +09:00
parent 2122966cd4
commit 2f9de149dd
2 changed files with 12 additions and 1 deletions

View File

@ -88,6 +88,17 @@ namespace osu.Game.Online.Chat
{ {
} }
/// <summary>
/// Create a private messaging channel with the specified user.
/// </summary>
/// <param name="user">The user to create the private conversation with.</param>
public Channel(User user)
{
Type = ChannelType.PM;
Users.Add(user);
Name = user.Username;
}
/// <summary> /// <summary>
/// Adds the argument message as a local echo. When this local echo is resolved <see cref="PendingMessageResolved"/> will get called. /// Adds the argument message as a local echo. When this local echo is resolved <see cref="PendingMessageResolved"/> will get called.
/// </summary> /// </summary>

View File

@ -79,7 +79,7 @@ namespace osu.Game.Online.Chat
throw new ArgumentNullException(nameof(user)); throw new ArgumentNullException(nameof(user));
CurrentChannel.Value = JoinedChannels.FirstOrDefault(c => c.Type == ChannelType.PM && c.Users.Count == 1 && c.Users.Any(u => u.Id == user.Id)) CurrentChannel.Value = JoinedChannels.FirstOrDefault(c => c.Type == ChannelType.PM && c.Users.Count == 1 && c.Users.Any(u => u.Id == user.Id))
?? new Channel { Name = user.Username, Users = { user }, Type = ChannelType.PM }; ?? new Channel(user);
} }
private void currentChannelChanged(Channel channel) => JoinChannel(channel); private void currentChannelChanged(Channel channel) => JoinChannel(channel);