From e59ac9e7c8e7af67e955c82865c5b422e21c8964 Mon Sep 17 00:00:00 2001 From: Dan Balasescu Date: Fri, 22 Nov 2024 17:19:26 +0900 Subject: [PATCH 1/2] No longer remove expired playlist items from `Room` model --- osu.Game/Online/Rooms/Room.cs | 11 ----------- .../OnlinePlay/Components/ListingPollingComponent.cs | 3 --- .../Components/SelectionPollingComponent.cs | 1 - 3 files changed, 15 deletions(-) diff --git a/osu.Game/Online/Rooms/Room.cs b/osu.Game/Online/Rooms/Room.cs index 486f70c0eda7..729074c5b61b 100644 --- a/osu.Game/Online/Rooms/Room.cs +++ b/osu.Game/Online/Rooms/Room.cs @@ -388,21 +388,10 @@ public void CopyFrom(Room other) CurrentPlaylistItem = other.CurrentPlaylistItem; AutoSkip = other.AutoSkip; - other.RemoveExpiredPlaylistItems(); - Playlist = other.Playlist; RecentParticipants = other.RecentParticipants; } - public void RemoveExpiredPlaylistItems() - { - // Todo: This is not the best way/place to do this, but the intention is to display all playlist items when the room has ended, - // and display only the non-expired playlist items while the room is still active. In order to achieve this, all expired items are removed from the source Room. - // More refactoring is required before this can be done locally instead - DrawableRoomPlaylist is currently directly bound to the playlist to display items in the room. - if (Status is not RoomStatusEnded) - Playlist = Playlist.Where(i => !i.Expired).ToArray(); - } - [JsonObject(MemberSerialization.OptIn)] public class RoomPlaylistItemStats { diff --git a/osu.Game/Screens/OnlinePlay/Components/ListingPollingComponent.cs b/osu.Game/Screens/OnlinePlay/Components/ListingPollingComponent.cs index b10ce8ed1ba6..b213d424dfa4 100644 --- a/osu.Game/Screens/OnlinePlay/Components/ListingPollingComponent.cs +++ b/osu.Game/Screens/OnlinePlay/Components/ListingPollingComponent.cs @@ -60,10 +60,7 @@ protected override Task Poll() } foreach (var incoming in result) - { - incoming.RemoveExpiredPlaylistItems(); RoomManager.AddOrUpdateRoom(incoming); - } initialRoomsReceived.Value = true; tcs.SetResult(true); diff --git a/osu.Game/Screens/OnlinePlay/Components/SelectionPollingComponent.cs b/osu.Game/Screens/OnlinePlay/Components/SelectionPollingComponent.cs index 8b80228ae1ce..7cee8b3546c1 100644 --- a/osu.Game/Screens/OnlinePlay/Components/SelectionPollingComponent.cs +++ b/osu.Game/Screens/OnlinePlay/Components/SelectionPollingComponent.cs @@ -36,7 +36,6 @@ protected override Task Poll() req.Success += result => { - result.RemoveExpiredPlaylistItems(); RoomManager.AddOrUpdateRoom(result); tcs.SetResult(true); }; From 39504c348dded475b64b6dbdb88b7abd6a7a1941 Mon Sep 17 00:00:00 2001 From: Dan Balasescu Date: Fri, 22 Nov 2024 17:22:30 +0900 Subject: [PATCH 2/2] Cleanup `CopyFrom()` method Though the code appears slightly different, it should be semantically equivalent. APIUser equality is implemented on `Id` and `Host` should never transition from non-null to null. --- osu.Game/Online/Rooms/Room.cs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/osu.Game/Online/Rooms/Room.cs b/osu.Game/Online/Rooms/Room.cs index 729074c5b61b..e1813c7e4e95 100644 --- a/osu.Game/Online/Rooms/Room.cs +++ b/osu.Game/Online/Rooms/Room.cs @@ -366,12 +366,8 @@ public void CopyFrom(Room other) { RoomID = other.RoomID; Name = other.Name; - Category = other.Category; - - if (other.Host != null && Host?.Id != other.Host.Id) - Host = other.Host; - + Host = other.Host; ChannelId = other.ChannelId; Status = other.Status; Availability = other.Availability; @@ -387,7 +383,6 @@ public void CopyFrom(Room other) PlaylistItemStats = other.PlaylistItemStats; CurrentPlaylistItem = other.CurrentPlaylistItem; AutoSkip = other.AutoSkip; - Playlist = other.Playlist; RecentParticipants = other.RecentParticipants; }