Refactor delayed load logic to hopefully read better

This commit is contained in:
Dean Herbert 2024-01-09 01:08:17 +09:00
parent 81c6fd5589
commit e77d203a24
No known key found for this signature in database

View File

@ -199,8 +199,16 @@ namespace osu.Game.Screens.Select.Carousel
Debug.Assert(Item != null);
if (loadCancellation == null && (timeSinceUnpool += Time.Elapsed) > timeUpdatingBeforeLoad)
{
// A load is already in progress if the cancellation token is non-null.
if (loadCancellation != null)
return;
timeSinceUnpool += Time.Elapsed;
// We only trigger a load after this set has been in an updating state for a set amount of time.
if (timeSinceUnpool <= timeUpdatingBeforeLoad)
return;
loadCancellation = new CancellationTokenSource();
LoadComponentsAsync(new CompositeDrawable[]
@ -220,7 +228,6 @@ namespace osu.Game.Screens.Select.Carousel
drawables.ForEach(d => d.FadeInFromZero(150));
}, loadCancellation.Token);
}
}
private void updateBeatmapYPositions()
{