private void handleMarkChannelAsReadRequest(MarkChannelAsReadRequest request) { // only accept messages that were sent through the API if (sentMessages.Contains(request.Message)) { request.TriggerSuccess(); } else { request.TriggerFailure(new APIException("unknown message!", null)); } }
/// <summary> /// Marks the <paramref name="channel"/> as read /// </summary> /// <param name="channel">The channel that will be marked as read</param> public void MarkChannelAsRead(Channel channel) { if (channel.LastMessageId == channel.LastReadId) return; var message = channel.Messages.LastOrDefault(); if (message == null) return; var req = new MarkChannelAsReadRequest(channel, message); req.Success += () => channel.LastReadId = message.Id; req.Failure += e => Logger.Error(e, $"Failed to mark channel {channel} up to '{message}' as read"); api.Queue(req); }
public void MarkChannelAsRead(Channel channel) { if (channel.LastMessageId == channel.LastReadId) { return; } var message = channel.Messages.FindLast(msg => !(msg is LocalMessage)); if (message == null) { return; } var req = new MarkChannelAsReadRequest(channel, message); req.Success += () => channel.LastReadId = message.Id; req.Failure += e => Logger.Log($"Failed to mark channel {channel} up to '{message}' as read ({e.Message})", LoggingTarget.Network); api.Queue(req); }