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

Initial commit

This commit is contained in:
Craftplacer 2020-01-02 17:07:28 +01:00
parent 9f5f78e443
commit 7b71e56817
3 changed files with 37 additions and 0 deletions

View File

@ -0,0 +1,21 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using osu.Game.Online.Chat;
namespace osu.Game.Online.API.Requests
{
public class MarkChannelAsReadRequest : APIRequest
{
private readonly Channel channel;
private readonly Message message;
public MarkChannelAsReadRequest(Channel channel, Message message)
{
this.channel = channel;
this.message = message;
}
protected override string Target => @"/chat/channels/{channel}/mark-as-read/{message}";
}
}

View File

@ -36,6 +36,11 @@ namespace osu.Game.Online.Chat
/// </summary>
public readonly SortedList<Message> Messages = new SortedList<Message>(Comparer<Message>.Default);
/// <summary>
/// Contains all the messages that weren't read by the user.
/// </summary>
public IEnumerable<Message> UnreadMessages => Messages.Where(m => LastReadId < m.Id);
/// <summary>
/// Contains all the messages that are still pending for submission to the server.
/// </summary>
@ -75,6 +80,9 @@ namespace osu.Game.Online.Chat
[JsonProperty(@"last_message_id")]
public long? LastMessageId;
[JsonProperty(@"last_read_id")]
public long? LastReadId;
/// <summary>
/// Signalles if the current user joined this channel or not. Defaults to false.
/// </summary>

View File

@ -445,6 +445,14 @@ namespace osu.Game.Online.Chat
return tcs.Task;
}
public void MarkChannelAsRead(Message message)
{
var channel = JoinedChannels.First(c => c.Id == message.ChannelId);
var req = new MarkChannelAsReadRequest(channel, message);
req.Success += () => channel.LastReadId = message.Id;
api.Queue(req);
}
[BackgroundDependencyLoader]
private void load(IAPIProvider api)
{