From 0f1bf35bd9131aa30ecce9ef39ccf50c96baf9b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Thu, 23 Oct 2025 12:48:41 +0200 Subject: [PATCH] Add favourite beatmap set tracking to `LocalUserInfo` --- osu.Game/Online/API/DummyAPIAccess.cs | 6 ++++++ osu.Game/Online/API/ILocalUserState.cs | 2 ++ osu.Game/Online/API/LocalUserState.cs | 22 ++++++++++++++++++++++ 3 files changed, 30 insertions(+) diff --git a/osu.Game/Online/API/DummyAPIAccess.cs b/osu.Game/Online/API/DummyAPIAccess.cs index dbf5964416..c01d0ca480 100644 --- a/osu.Game/Online/API/DummyAPIAccess.cs +++ b/osu.Game/Online/API/DummyAPIAccess.cs @@ -238,10 +238,12 @@ namespace osu.Game.Online.API public BindableList Friends { get; } = new BindableList(); public BindableList Blocks { get; } = new BindableList(); + public BindableList FavouriteBeatmapSets { get; } = new BindableList(); IBindable ILocalUserState.User => User; IBindableList ILocalUserState.Friends => Friends; IBindableList ILocalUserState.Blocks => Blocks; + IBindableList ILocalUserState.FavouriteBeatmapSets => FavouriteBeatmapSets; public void UpdateFriends() { @@ -250,6 +252,10 @@ namespace osu.Game.Online.API public void UpdateBlocks() { } + + public void UpdateFavouriteBeatmapSets() + { + } } } } diff --git a/osu.Game/Online/API/ILocalUserState.cs b/osu.Game/Online/API/ILocalUserState.cs index 3ccec1c9ae..4c5cbcf197 100644 --- a/osu.Game/Online/API/ILocalUserState.cs +++ b/osu.Game/Online/API/ILocalUserState.cs @@ -11,8 +11,10 @@ namespace osu.Game.Online.API IBindable User { get; } IBindableList Friends { get; } IBindableList Blocks { get; } + IBindableList FavouriteBeatmapSets { get; } void UpdateFriends(); void UpdateBlocks(); + void UpdateFavouriteBeatmapSets(); } } diff --git a/osu.Game/Online/API/LocalUserState.cs b/osu.Game/Online/API/LocalUserState.cs index 5da9289d89..1359d62ae7 100644 --- a/osu.Game/Online/API/LocalUserState.cs +++ b/osu.Game/Online/API/LocalUserState.cs @@ -16,12 +16,14 @@ namespace osu.Game.Online.API public IBindable User => localUser; public IBindableList Friends => friends; public IBindableList Blocks => blocks; + public IBindableList FavouriteBeatmapSets => favouriteBeatmapSets; private readonly IAPIProvider api; private readonly Bindable localUser = new Bindable(createGuestUser()); private readonly BindableList friends = new BindableList(); private readonly BindableList blocks = new BindableList(); + private readonly BindableList favouriteBeatmapSets = new BindableList(); private readonly Bindable configStatus = new Bindable(); private readonly Bindable configSupporter = new Bindable(); @@ -62,6 +64,7 @@ namespace osu.Game.Online.API UpdateFriends(); UpdateBlocks(); + UpdateFavouriteBeatmapSets(); } public void ClearLocalUser() @@ -76,6 +79,7 @@ namespace osu.Game.Online.API configSupporter.Value = false; friends.Clear(); blocks.Clear(); + favouriteBeatmapSets.Clear(); }); } @@ -125,5 +129,23 @@ namespace osu.Game.Online.API api.Queue(blocksReq); } + + public void UpdateFavouriteBeatmapSets() + { + if (!api.IsLoggedIn) + return; + + var favouritesReq = new GetMyFavouriteBeatmapSetsRequest(); + favouritesReq.Success += res => + { + var existingBeatmapSets = favouriteBeatmapSets.ToHashSet(); + var updatedBeatmapSets = res.BeatmapSetIds.ToHashSet(); + + favouriteBeatmapSets.AddRange(updatedBeatmapSets.Except(existingBeatmapSets)); + favouriteBeatmapSets.RemoveAll(b => !updatedBeatmapSets.Contains(b)); + }; + + api.Queue(favouritesReq); + } } }