1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 16:27:26 +08:00

Simplify mirror copy of task logic in ModColumn

This commit is contained in:
Bartłomiej Dach 2022-08-08 19:20:50 +02:00
parent 00333fb0d2
commit f21a51aa24
No known key found for this signature in database
GPG Key ID: BCECCD4FA41F6497

View File

@ -66,7 +66,7 @@ namespace osu.Game.Overlays.Mods
private IModHotkeyHandler hotkeyHandler = null!;
private Task? latestLoadTask;
internal bool ItemsLoaded => latestLoadTask == null;
internal bool ItemsLoaded => latestLoadTask?.IsCompleted == true;
public ModColumn(ModType modType, bool allowIncompatibleSelection)
{
@ -132,18 +132,11 @@ namespace osu.Game.Overlays.Mods
var panels = availableMods.Select(mod => CreateModPanel(mod).With(panel => panel.Shear = Vector2.Zero));
Task? loadTask;
latestLoadTask = loadTask = LoadComponentsAsync(panels, loaded =>
latestLoadTask = LoadComponentsAsync(panels, loaded =>
{
ItemsFlow.ChildrenEnumerable = loaded;
updateState();
}, (cancellationTokenSource = new CancellationTokenSource()).Token);
loadTask.ContinueWith(_ =>
{
if (loadTask == latestLoadTask)
latestLoadTask = null;
});
}
private void updateState()