1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 13:37:25 +08:00

Combine multiple similar invalidation logic into single event

This commit is contained in:
Dean Herbert 2023-12-18 20:00:57 +09:00
parent 41f5a6e292
commit 32cc3f9ef7
No known key found for this signature in database

View File

@ -168,7 +168,7 @@ namespace osu.Game.Screens.Select
applyActiveCriteria(false); applyActiveCriteria(false);
if (loadedTestBeatmaps) if (loadedTestBeatmaps)
signalBeatmapsLoaded(); invalidateAfterChange(true);
// Restore selection // Restore selection
if (selectedBeatmapBefore != null && newRoot.BeatmapSetsByID.TryGetValue(selectedBeatmapBefore.BeatmapSet!.ID, out var newSelectionCandidates)) if (selectedBeatmapBefore != null && newRoot.BeatmapSetsByID.TryGetValue(selectedBeatmapBefore.BeatmapSet!.ID, out var newSelectionCandidates))
@ -298,7 +298,8 @@ namespace osu.Game.Screens.Select
removeBeatmapSet(id); removeBeatmapSet(id);
} }
signalBeatmapsLoaded(); invalidateAfterChange(!BeatmapSetsLoaded);
BeatmapSetsLoaded = true;
return; return;
} }
@ -393,12 +394,7 @@ namespace osu.Game.Screens.Select
root.RemoveItem(set); root.RemoveItem(set);
} }
itemsCache.Invalidate(); invalidateAfterChange(true);
if (!Scroll.UserScrolling)
ScrollToSelected(true);
BeatmapSetsChanged?.Invoke();
}); });
public void UpdateBeatmapSet(BeatmapSetInfo beatmapSet) => Schedule(() => public void UpdateBeatmapSet(BeatmapSetInfo beatmapSet) => Schedule(() =>
@ -465,12 +461,7 @@ namespace osu.Game.Screens.Select
} }
} }
itemsCache.Invalidate(); invalidateAfterChange(true);
if (!Scroll.UserScrolling)
ScrollToSelected(true);
BeatmapSetsChanged?.Invoke();
}); });
/// <summary> /// <summary>
@ -748,15 +739,15 @@ namespace osu.Game.Screens.Select
} }
} }
private void signalBeatmapsLoaded() private void invalidateAfterChange(bool invokeSetsChangedEvent)
{ {
if (!BeatmapSetsLoaded)
{
BeatmapSetsChanged?.Invoke();
BeatmapSetsLoaded = true;
}
itemsCache.Invalidate(); itemsCache.Invalidate();
if (!Scroll.UserScrolling)
ScrollToSelected(true);
if (invokeSetsChangedEvent)
BeatmapSetsChanged?.Invoke();
} }
private float? scrollTarget; private float? scrollTarget;