Fix test failures by waiting for panel load

This commit is contained in:
Bartłomiej Dach
2022-02-28 21:36:13 +01:00
parent 42b27e3050
commit 6cc972aa6a
2 changed files with 19 additions and 3 deletions

View File

@ -5,6 +5,7 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Humanizer;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
@ -56,6 +57,9 @@ namespace osu.Game.Overlays.Mods
private Colour4 accentColour;
private Task? latestLoadTask;
internal bool ItemsLoaded => latestLoadTask == null;
private const float header_height = 42;
public ModColumn(ModType modType, bool allowBulkSelection, Key[]? toggleKeys = null)
@ -234,7 +238,9 @@ namespace osu.Game.Overlays.Mods
Shear = new Vector2(-ModPanel.SHEAR_X, 0)
});
LoadComponentsAsync(panels, loaded =>
Task? loadTask;
latestLoadTask = loadTask = LoadComponentsAsync(panels, loaded =>
{
panelFlow.ChildrenEnumerable = loaded;
@ -244,6 +250,11 @@ namespace osu.Game.Overlays.Mods
updateFilter();
}, (cancellationTokenSource = new CancellationTokenSource()).Token);
loadTask.ContinueWith(_ =>
{
if (loadTask == latestLoadTask)
latestLoadTask = null;
});
}
#region Bulk select / deselect