From 6687cc062dac25e3d493f7b67e235a958c2e47fc Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 12 May 2026 19:11:07 +0900 Subject: [PATCH] Fix song select local ranks disappearing on beatmap downloads (#37711) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Rather than a complete regression from https://github.com/ppy/osu/pull/37666, the change I made to hide stale ranks revealed that this subscription was being reinitialised *way* too often. Relevant call stack: 2026-05-12 02 15 58@2x --------- Co-authored-by: Bartłomiej Dach --- .../Screens/Select/PanelLocalRankDisplay.cs | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/osu.Game/Screens/Select/PanelLocalRankDisplay.cs b/osu.Game/Screens/Select/PanelLocalRankDisplay.cs index 8886bad420..1d93ff3ab6 100644 --- a/osu.Game/Screens/Select/PanelLocalRankDisplay.cs +++ b/osu.Game/Screens/Select/PanelLocalRankDisplay.cs @@ -10,6 +10,7 @@ using osu.Framework.Graphics.Containers; using osu.Game.Beatmaps; using osu.Game.Database; using osu.Game.Online.API; +using osu.Game.Online.API.Requests.Responses; using osu.Game.Online.Leaderboards; using osu.Game.Rulesets; using osu.Game.Scoring; @@ -27,6 +28,9 @@ namespace osu.Game.Screens.Select get => beatmap; set { + if (beatmap?.Equals(value) == true) + return; + beatmap = value; if (IsLoaded) @@ -40,8 +44,7 @@ namespace osu.Game.Screens.Select [Resolved] private RealmAccess realm { get; set; } = null!; - [Resolved] - private IAPIProvider api { get; set; } = null!; + private readonly IBindable localUser = new Bindable(); private IDisposable? scoreSubscription; @@ -62,11 +65,18 @@ namespace osu.Game.Screens.Select Beatmap = beatmap; } + [BackgroundDependencyLoader] + private void load(IAPIProvider api) + { + localUser.BindTo(api.LocalUser); + } + protected override void LoadComplete() { base.LoadComplete(); - ruleset.BindValueChanged(_ => updateSubscription(), true); + ruleset.BindValueChanged(_ => updateSubscription()); + localUser.BindValueChanged(_ => updateSubscription(), true); } private void updateSubscription() @@ -89,7 +99,7 @@ namespace osu.Game.Screens.Select ScoreInfo? topScore = sender // doing these post realm filter is most efficient. - .Where(s => s.UserID == api.LocalUser.Value.Id || s.UserID <= 1) + .Where(s => s.UserID == localUser.Value.Id || s.UserID <= 1) .Where(s => ruleset.Value.Equals(s.Ruleset)) .MaxBy(info => (info.TotalScore, -info.Date.UtcDateTime.Ticks));