From 1776d38809fbea7994614c34c489a7d740832089 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 28 Aug 2024 20:06:44 +0900 Subject: [PATCH] Remove `loadedTestBeatmaps` flag --- osu.Game/Screens/Select/BeatmapCarousel.cs | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/osu.Game/Screens/Select/BeatmapCarousel.cs b/osu.Game/Screens/Select/BeatmapCarousel.cs index 20899d1869..7f6921d768 100644 --- a/osu.Game/Screens/Select/BeatmapCarousel.cs +++ b/osu.Game/Screens/Select/BeatmapCarousel.cs @@ -116,15 +116,12 @@ namespace osu.Game.Screens.Select [Resolved] private DetachedBeatmapStore? detachedBeatmapStore { get; set; } - private IBindableList detachedBeatmapSets = null!; + private IBindableList? detachedBeatmapSets; private readonly NoResultsPlaceholder noResultsPlaceholder; private IEnumerable beatmapSets => root.Items.OfType(); - // todo: only used for testing, maybe remove. - private bool loadedTestBeatmaps; - public IEnumerable BeatmapSets { get => beatmapSets.Select(g => g.BeatmapSet); @@ -133,7 +130,6 @@ namespace osu.Game.Screens.Select if (LoadState != LoadState.NotLoaded) throw new InvalidOperationException("If not using a realm source, beatmap sets must be set before load."); - loadedTestBeatmaps = true; detachedBeatmapSets = new BindableList(value); Schedule(loadNewRoot); } @@ -143,7 +139,7 @@ namespace osu.Game.Screens.Select { // Ensure no changes are made to the list while we are initialising items. // We'll catch up on changes via subscriptions anyway. - BeatmapSetInfo[] loadableSets = detachedBeatmapSets.ToArray(); + BeatmapSetInfo[] loadableSets = detachedBeatmapSets!.ToArray(); if (selectedBeatmapSet != null && !loadableSets.Contains(selectedBeatmapSet.BeatmapSet)) selectedBeatmapSet = null; @@ -256,7 +252,7 @@ namespace osu.Game.Screens.Select RightClickScrollingEnabled.ValueChanged += enabled => Scroll.RightMouseScrollbar = enabled.NewValue; RightClickScrollingEnabled.TriggerChange(); - if (!loadedTestBeatmaps && detachedBeatmapStore != null) + if (detachedBeatmapStore != null && detachedBeatmapSets == null) { // This is performing an unnecessary second lookup on realm (in addition to the subscription), but for performance reasons // we require it to be separate: the subscription's initial callback (with `ChangeSet` of `null`) will run on the update @@ -279,10 +275,6 @@ namespace osu.Game.Screens.Select private void beatmapSetsChanged(object? beatmaps, NotifyCollectionChangedEventArgs changed) { - // If loading test beatmaps, avoid overwriting with realm subscription callbacks. - if (loadedTestBeatmaps) - return; - IEnumerable? newBeatmapSets = changed.NewItems?.Cast(); switch (changed.Action)