From 7b71e568177f1d827316dd3930ac64fd2921f5c0 Mon Sep 17 00:00:00 2001 From: Craftplacer Date: Thu, 2 Jan 2020 17:07:28 +0100 Subject: [PATCH 01/20] Initial commit --- .../API/Requests/MarkChannelAsReadRequest.cs | 21 +++++++++++++++++++ osu.Game/Online/Chat/Channel.cs | 8 +++++++ osu.Game/Online/Chat/ChannelManager.cs | 8 +++++++ 3 files changed, 37 insertions(+) create mode 100644 osu.Game/Online/API/Requests/MarkChannelAsReadRequest.cs diff --git a/osu.Game/Online/API/Requests/MarkChannelAsReadRequest.cs b/osu.Game/Online/API/Requests/MarkChannelAsReadRequest.cs new file mode 100644 index 0000000000..3f28037816 --- /dev/null +++ b/osu.Game/Online/API/Requests/MarkChannelAsReadRequest.cs @@ -0,0 +1,21 @@ +// Copyright (c) ppy Pty Ltd . 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}"; + } +} diff --git a/osu.Game/Online/Chat/Channel.cs b/osu.Game/Online/Chat/Channel.cs index 451174a73c..6f67a95f53 100644 --- a/osu.Game/Online/Chat/Channel.cs +++ b/osu.Game/Online/Chat/Channel.cs @@ -36,6 +36,11 @@ namespace osu.Game.Online.Chat /// public readonly SortedList Messages = new SortedList(Comparer.Default); + /// + /// Contains all the messages that weren't read by the user. + /// + public IEnumerable UnreadMessages => Messages.Where(m => LastReadId < m.Id); + /// /// Contains all the messages that are still pending for submission to the server. /// @@ -75,6 +80,9 @@ namespace osu.Game.Online.Chat [JsonProperty(@"last_message_id")] public long? LastMessageId; + [JsonProperty(@"last_read_id")] + public long? LastReadId; + /// /// Signalles if the current user joined this channel or not. Defaults to false. /// diff --git a/osu.Game/Online/Chat/ChannelManager.cs b/osu.Game/Online/Chat/ChannelManager.cs index 1d8c5609d9..e92a4853ff 100644 --- a/osu.Game/Online/Chat/ChannelManager.cs +++ b/osu.Game/Online/Chat/ChannelManager.cs @@ -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) { From 51556a809d578f159387664cf23ce26a856643b1 Mon Sep 17 00:00:00 2001 From: Craftplacer Date: Thu, 2 Jan 2020 17:20:33 +0100 Subject: [PATCH 02/20] Fix variables not being used inside target string --- osu.Game/Online/API/Requests/MarkChannelAsReadRequest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Online/API/Requests/MarkChannelAsReadRequest.cs b/osu.Game/Online/API/Requests/MarkChannelAsReadRequest.cs index 3f28037816..76c925588b 100644 --- a/osu.Game/Online/API/Requests/MarkChannelAsReadRequest.cs +++ b/osu.Game/Online/API/Requests/MarkChannelAsReadRequest.cs @@ -16,6 +16,6 @@ namespace osu.Game.Online.API.Requests this.message = message; } - protected override string Target => @"/chat/channels/{channel}/mark-as-read/{message}"; + protected override string Target => $"/chat/channels/{channel}/mark-as-read/{message}"; } } From 9b95ce1045e0d1eba172e41cf96367e656bedffd Mon Sep 17 00:00:00 2001 From: Craftplacer Date: Sat, 4 Jan 2020 00:45:02 +0100 Subject: [PATCH 03/20] Change wrong values used to form target URL Dumb mistake by me, C# used ToString() on these objects. --- osu.Game/Online/API/Requests/MarkChannelAsReadRequest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Online/API/Requests/MarkChannelAsReadRequest.cs b/osu.Game/Online/API/Requests/MarkChannelAsReadRequest.cs index 76c925588b..689fd7e485 100644 --- a/osu.Game/Online/API/Requests/MarkChannelAsReadRequest.cs +++ b/osu.Game/Online/API/Requests/MarkChannelAsReadRequest.cs @@ -16,6 +16,6 @@ namespace osu.Game.Online.API.Requests this.message = message; } - protected override string Target => $"/chat/channels/{channel}/mark-as-read/{message}"; + protected override string Target => $"chat/channels/{channel.Id}/mark-as-read/{message.Id}"; } } From 8dbddfab559830ffe19f3c675af4ca0367a296d3 Mon Sep 17 00:00:00 2001 From: Craftplacer Date: Sat, 4 Jan 2020 00:45:51 +0100 Subject: [PATCH 04/20] Add HTTP method --- osu.Game/Online/API/Requests/MarkChannelAsReadRequest.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/osu.Game/Online/API/Requests/MarkChannelAsReadRequest.cs b/osu.Game/Online/API/Requests/MarkChannelAsReadRequest.cs index 689fd7e485..95a5d0acbd 100644 --- a/osu.Game/Online/API/Requests/MarkChannelAsReadRequest.cs +++ b/osu.Game/Online/API/Requests/MarkChannelAsReadRequest.cs @@ -1,6 +1,8 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using System.Net.Http; +using osu.Framework.IO.Network; using osu.Game.Online.Chat; namespace osu.Game.Online.API.Requests @@ -17,5 +19,12 @@ namespace osu.Game.Online.API.Requests } protected override string Target => $"chat/channels/{channel.Id}/mark-as-read/{message.Id}"; + + protected override WebRequest CreateWebRequest() + { + var req = base.CreateWebRequest(); + req.Method = HttpMethod.Put; + return req; + } } } From 4f36bc0fd399a69194d10535ea9c61c8c51f395d Mon Sep 17 00:00:00 2001 From: Craftplacer Date: Sat, 4 Jan 2020 00:49:35 +0100 Subject: [PATCH 05/20] Add error log message for debugging --- osu.Game/Online/Chat/ChannelManager.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/osu.Game/Online/Chat/ChannelManager.cs b/osu.Game/Online/Chat/ChannelManager.cs index e92a4853ff..6eb1674f37 100644 --- a/osu.Game/Online/Chat/ChannelManager.cs +++ b/osu.Game/Online/Chat/ChannelManager.cs @@ -450,6 +450,7 @@ namespace osu.Game.Online.Chat var channel = JoinedChannels.First(c => c.Id == message.ChannelId); var req = new MarkChannelAsReadRequest(channel, message); req.Success += () => channel.LastReadId = message.Id; + req.Failure += (e) => Logger.Error(e, "Failed to mark channel as read"); api.Queue(req); } From 7cc388b5abc56b5d49d9fabe9596db1701b22641 Mon Sep 17 00:00:00 2001 From: Craftplacer Date: Sat, 4 Jan 2020 00:50:12 +0100 Subject: [PATCH 06/20] Mark channel up to last message as read when switching channels --- osu.Game/Overlays/ChatOverlay.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/osu.Game/Overlays/ChatOverlay.cs b/osu.Game/Overlays/ChatOverlay.cs index e80c51d82a..b64d3a1893 100644 --- a/osu.Game/Overlays/ChatOverlay.cs +++ b/osu.Game/Overlays/ChatOverlay.cs @@ -279,6 +279,10 @@ namespace osu.Game.Overlays currentChannelContainer.Clear(false); currentChannelContainer.Add(loaded); } + + // mark channel as read when channel switched + if (e.NewValue.Messages.Any()) + channelManager.MarkChannelAsRead(e.NewValue.Messages.Last()); } private float startDragChatHeight; From cd91cc860d52f029fc77b32034eb966cf4a08bba Mon Sep 17 00:00:00 2001 From: Craftplacer Date: Sat, 4 Jan 2020 01:06:38 +0100 Subject: [PATCH 07/20] Resolve "Redundant lambda signature parentheses" --- osu.Game/Online/Chat/ChannelManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Online/Chat/ChannelManager.cs b/osu.Game/Online/Chat/ChannelManager.cs index 6eb1674f37..19c3be0d7b 100644 --- a/osu.Game/Online/Chat/ChannelManager.cs +++ b/osu.Game/Online/Chat/ChannelManager.cs @@ -450,7 +450,7 @@ namespace osu.Game.Online.Chat var channel = JoinedChannels.First(c => c.Id == message.ChannelId); 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 as read"); api.Queue(req); } From bd175118e9a5075c396a4dfb578729f6d1a7ff89 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sat, 11 Jan 2020 04:16:07 +0800 Subject: [PATCH 08/20] Update framework --- osu.Android.props | 2 +- osu.Game/osu.Game.csproj | 2 +- osu.iOS.props | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/osu.Android.props b/osu.Android.props index fde58ec489..f3838644d1 100644 --- a/osu.Android.props +++ b/osu.Android.props @@ -54,6 +54,6 @@ - + diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 04d0b580da..4fc9e47119 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -23,7 +23,7 @@ - + diff --git a/osu.iOS.props b/osu.iOS.props index 50aabd636a..760600e6d4 100644 --- a/osu.iOS.props +++ b/osu.iOS.props @@ -74,7 +74,7 @@ - + @@ -82,7 +82,7 @@ - + From 19033e0ef85fba4086d303825718de15affc268c Mon Sep 17 00:00:00 2001 From: Joehu Date: Fri, 10 Jan 2020 19:25:33 -0800 Subject: [PATCH 09/20] Fix user status dropdown having no padding around items --- osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs b/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs index 27796c1e32..e485aa5ea9 100644 --- a/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs @@ -323,8 +323,6 @@ namespace osu.Game.Overlays.Settings.Sections.General Colour = Color4.Black.Opacity(0.25f), Radius = 4, }; - - ItemsContainer.Padding = new MarginPadding(); } [BackgroundDependencyLoader] From 820f9f2273f98995c2da7c40427e43b3d0ca0ae8 Mon Sep 17 00:00:00 2001 From: Joehu Date: Fri, 10 Jan 2020 20:16:46 -0800 Subject: [PATCH 10/20] Fix default button absorbing drag scroll on settings --- osu.Game/Overlays/Settings/SettingsItem.cs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/osu.Game/Overlays/Settings/SettingsItem.cs b/osu.Game/Overlays/Settings/SettingsItem.cs index 35f28ab1b2..55e1937d83 100644 --- a/osu.Game/Overlays/Settings/SettingsItem.cs +++ b/osu.Game/Overlays/Settings/SettingsItem.cs @@ -163,10 +163,6 @@ namespace osu.Game.Overlays.Settings public string TooltipText => "Revert to default"; - protected override bool OnMouseDown(MouseDownEvent e) => true; - - protected override bool OnMouseUp(MouseUpEvent e) => true; - protected override bool OnClick(ClickEvent e) { if (bindable != null && !bindable.Disabled) From 76c70a76229a956c186d304c9232a604015148e8 Mon Sep 17 00:00:00 2001 From: mcendu Date: Sat, 11 Jan 2020 21:19:46 +0800 Subject: [PATCH 11/20] Move hit target bar height def to defaulthittarget --- osu.Game.Rulesets.Mania/UI/Components/ColumnHitObjectArea.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game.Rulesets.Mania/UI/Components/ColumnHitObjectArea.cs b/osu.Game.Rulesets.Mania/UI/Components/ColumnHitObjectArea.cs index ee2cec1bbd..90e78c3899 100644 --- a/osu.Game.Rulesets.Mania/UI/Components/ColumnHitObjectArea.cs +++ b/osu.Game.Rulesets.Mania/UI/Components/ColumnHitObjectArea.cs @@ -18,8 +18,6 @@ namespace osu.Game.Rulesets.Mania.UI.Components { public class ColumnHitObjectArea : CompositeDrawable, IHasAccentColour { - private const float hit_target_bar_height = 2; - private readonly IBindable direction = new Bindable(); private readonly Drawable hitTarget; @@ -67,6 +65,8 @@ namespace osu.Game.Rulesets.Mania.UI.Components private class DefaultHitTarget : CompositeDrawable, IHasAccentColour { + private const float hit_target_bar_height = 2; + private readonly IBindable direction = new Bindable(); private readonly Container hitTargetLine; From ec95cbd0affc9e9c91817459740f46f4ba964a4d Mon Sep 17 00:00:00 2001 From: Lucas A Date: Sat, 11 Jan 2020 16:03:00 +0100 Subject: [PATCH 12/20] Don't update rich presence if the rpc client isn't initialized. --- osu.Desktop/DiscordRichPresence.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/osu.Desktop/DiscordRichPresence.cs b/osu.Desktop/DiscordRichPresence.cs index 80bb82c769..08cc0e7f5f 100644 --- a/osu.Desktop/DiscordRichPresence.cs +++ b/osu.Desktop/DiscordRichPresence.cs @@ -75,6 +75,9 @@ namespace osu.Desktop private void updateStatus() { + if (!client.IsInitialized) + return; + if (status.Value is UserStatusOffline) { client.ClearPresence(); From cd679707eddc4aa2a4ff911e4da1221526bc3a2a Mon Sep 17 00:00:00 2001 From: Craftplacer Date: Sat, 11 Jan 2020 17:16:11 +0100 Subject: [PATCH 13/20] Prevent channel duplicates MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Bartłomiej Dach --- osu.Game/Online/Chat/ChannelManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Online/Chat/ChannelManager.cs b/osu.Game/Online/Chat/ChannelManager.cs index 19c3be0d7b..33b0c0e9e1 100644 --- a/osu.Game/Online/Chat/ChannelManager.cs +++ b/osu.Game/Online/Chat/ChannelManager.cs @@ -447,7 +447,7 @@ namespace osu.Game.Online.Chat public void MarkChannelAsRead(Message message) { - var channel = JoinedChannels.First(c => c.Id == message.ChannelId); + var channel = JoinedChannels.Single(c => c.Id == message.ChannelId); var req = new MarkChannelAsReadRequest(channel, message); req.Success += () => channel.LastReadId = message.Id; req.Failure += e => Logger.Error(e, "Failed to mark channel as read"); From 50e357a79930b0980fb67fddafc21c65712a0c49 Mon Sep 17 00:00:00 2001 From: Craftplacer Date: Sat, 11 Jan 2020 17:42:02 +0100 Subject: [PATCH 14/20] Change method parameters, add detailed error message and method docs --- osu.Game/Online/Chat/ChannelManager.cs | 16 +++++++++++++--- osu.Game/Overlays/ChatOverlay.cs | 2 +- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/osu.Game/Online/Chat/ChannelManager.cs b/osu.Game/Online/Chat/ChannelManager.cs index 33b0c0e9e1..9f263477d0 100644 --- a/osu.Game/Online/Chat/ChannelManager.cs +++ b/osu.Game/Online/Chat/ChannelManager.cs @@ -445,12 +445,22 @@ namespace osu.Game.Online.Chat return tcs.Task; } - public void MarkChannelAsRead(Message message) + /// + /// Marks the as read + /// (see for more information) + /// + /// The channel that will be marked as read + /// The message where it will be read up to. If was provided, the latest message of the will be read. + 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); } diff --git a/osu.Game/Overlays/ChatOverlay.cs b/osu.Game/Overlays/ChatOverlay.cs index b64d3a1893..45d311df28 100644 --- a/osu.Game/Overlays/ChatOverlay.cs +++ b/osu.Game/Overlays/ChatOverlay.cs @@ -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; From d9c57baa89cab9430f3a9577666d0a8708096444 Mon Sep 17 00:00:00 2001 From: Craftplacer Date: Sat, 11 Jan 2020 17:48:03 +0100 Subject: [PATCH 15/20] Add test case for mismatch of channels --- osu.Game/Online/Chat/ChannelManager.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/osu.Game/Online/Chat/ChannelManager.cs b/osu.Game/Online/Chat/ChannelManager.cs index 9f263477d0..b30d1ffa60 100644 --- a/osu.Game/Online/Chat/ChannelManager.cs +++ b/osu.Game/Online/Chat/ChannelManager.cs @@ -3,6 +3,7 @@ using System; using System.Collections.Generic; +using System.Diagnostics; using System.Linq; using System.Threading.Tasks; using osu.Framework.Allocation; @@ -455,6 +456,8 @@ namespace osu.Game.Online.Chat { if (message == null) message = channel.Messages.Last(); + else + Debug.Assert(channel.Id == message.Id, "Provided channel and message owner channel aren't equal."); var req = new MarkChannelAsReadRequest(channel, message); From f8a11e50b677c4f3172efbbeae05eee81e713608 Mon Sep 17 00:00:00 2001 From: Craftplacer Date: Sat, 11 Jan 2020 18:00:34 +0100 Subject: [PATCH 16/20] Remove redundant ToString() calls as string interpolation does this automatically.. --- osu.Game/Online/Chat/ChannelManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Online/Chat/ChannelManager.cs b/osu.Game/Online/Chat/ChannelManager.cs index b30d1ffa60..5aab43dbd9 100644 --- a/osu.Game/Online/Chat/ChannelManager.cs +++ b/osu.Game/Online/Chat/ChannelManager.cs @@ -462,7 +462,7 @@ namespace osu.Game.Online.Chat var req = new MarkChannelAsReadRequest(channel, message); req.Success += () => channel.LastReadId = message.Id; - req.Failure += e => Logger.Error(e, $"Failed to mark channel {channel.ToString()} up to '{message.ToString()}' as read"); + req.Failure += e => Logger.Error(e, $"Failed to mark channel {channel} up to '{message}' as read"); api.Queue(req); } From 2ea1367a881cab6e5e9eed787971a6f5ca22f989 Mon Sep 17 00:00:00 2001 From: Craftplacer Date: Sat, 11 Jan 2020 19:47:35 +0100 Subject: [PATCH 17/20] Remove message parameter and make it mark the entire channel as read --- osu.Game/Online/Chat/ChannelManager.cs | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/osu.Game/Online/Chat/ChannelManager.cs b/osu.Game/Online/Chat/ChannelManager.cs index 5aab43dbd9..4071be0aaf 100644 --- a/osu.Game/Online/Chat/ChannelManager.cs +++ b/osu.Game/Online/Chat/ChannelManager.cs @@ -448,17 +448,11 @@ namespace osu.Game.Online.Chat /// /// Marks the as read - /// (see for more information) /// /// The channel that will be marked as read - /// The message where it will be read up to. If was provided, the latest message of the will be read. - public void MarkChannelAsRead(Channel channel, Message message = null) + public void MarkChannelAsRead(Channel channel) { - if (message == null) - message = channel.Messages.Last(); - else - Debug.Assert(channel.Id == message.Id, "Provided channel and message owner channel aren't equal."); - + var message = channel.Messages.Last(); var req = new MarkChannelAsReadRequest(channel, message); req.Success += () => channel.LastReadId = message.Id; From ccaf4e48a169644bafbfeafe006e9c71d57a5beb Mon Sep 17 00:00:00 2001 From: Craftplacer Date: Sat, 11 Jan 2020 20:04:58 +0100 Subject: [PATCH 18/20] Remove using directive --- osu.Game/Online/Chat/ChannelManager.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/osu.Game/Online/Chat/ChannelManager.cs b/osu.Game/Online/Chat/ChannelManager.cs index 4071be0aaf..35a48b7ec8 100644 --- a/osu.Game/Online/Chat/ChannelManager.cs +++ b/osu.Game/Online/Chat/ChannelManager.cs @@ -3,7 +3,6 @@ using System; using System.Collections.Generic; -using System.Diagnostics; using System.Linq; using System.Threading.Tasks; using osu.Framework.Allocation; From 8cc2d70df0fb725e09891caf912adb335841e31d Mon Sep 17 00:00:00 2001 From: Craftplacer Date: Sun, 12 Jan 2020 16:24:14 +0100 Subject: [PATCH 19/20] Reduce API calls by checking what message was last marked as read --- osu.Game/Online/Chat/ChannelManager.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/osu.Game/Online/Chat/ChannelManager.cs b/osu.Game/Online/Chat/ChannelManager.cs index 35a48b7ec8..b741bd9433 100644 --- a/osu.Game/Online/Chat/ChannelManager.cs +++ b/osu.Game/Online/Chat/ChannelManager.cs @@ -451,6 +451,9 @@ namespace osu.Game.Online.Chat /// The channel that will be marked as read public void MarkChannelAsRead(Channel channel) { + if (channel.LastMessageId == channel.LastReadId) + return; + var message = channel.Messages.Last(); var req = new MarkChannelAsReadRequest(channel, message); From c190c68659236e0e5b2d57945b7a52ee7d936a7f Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 13 Jan 2020 12:22:44 +0900 Subject: [PATCH 20/20] Add safety for channel with no messages --- osu.Game/Online/Chat/ChannelManager.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/osu.Game/Online/Chat/ChannelManager.cs b/osu.Game/Online/Chat/ChannelManager.cs index b741bd9433..4b5ec1cad0 100644 --- a/osu.Game/Online/Chat/ChannelManager.cs +++ b/osu.Game/Online/Chat/ChannelManager.cs @@ -454,7 +454,11 @@ namespace osu.Game.Online.Chat if (channel.LastMessageId == channel.LastReadId) return; - var message = channel.Messages.Last(); + var message = channel.Messages.LastOrDefault(); + + if (message == null) + return; + var req = new MarkChannelAsReadRequest(channel, message); req.Success += () => channel.LastReadId = message.Id;