Change method parameters, add detailed error message and method docs

This commit is contained in:
Craftplacer 2020-01-11 17:42:02 +01:00
parent cd679707ed
commit 50e357a799
2 changed files with 14 additions and 4 deletions

View File

@ -445,12 +445,22 @@ namespace osu.Game.Online.Chat
return tcs.Task;
}
public void MarkChannelAsRead(Message message)
/// <summary>
/// Marks the <paramref name="channel"/> as read
/// <see>(see <paramref name="message"/> for more information)</see>
/// </summary>
/// <param name="channel">The channel that will be marked as read</param>
/// <param name="message">The message where it will be read up to. If <see langword="null"/> was provided, the latest message of the <paramref name="channel"/> will be read.</param>
public void MarkChannelAsRead(Channel channel, Message message = null)
{
var channel = JoinedChannels.Single(c => c.Id == message.ChannelId);
if (message == null)
message = channel.Messages.Last();
var req = new MarkChannelAsReadRequest(channel, message);
req.Success += () => channel.LastReadId = message.Id;
req.Failure += e => Logger.Error(e, "Failed to mark channel as read");
req.Failure += e => Logger.Error(e, $"Failed to mark channel {channel.ToString()} up to '{message.ToString()}' as read");
api.Queue(req);
}

View File

@ -282,7 +282,7 @@ namespace osu.Game.Overlays
// mark channel as read when channel switched
if (e.NewValue.Messages.Any())
channelManager.MarkChannelAsRead(e.NewValue.Messages.Last());
channelManager.MarkChannelAsRead(e.NewValue);
}
private float startDragChatHeight;