1
0
mirror of https://github.com/ppy/osu.git synced 2026-06-03 18:03:55 +08:00

Async load panels to avoid update thread hitching

This commit is contained in:
Bartłomiej Dach
2025-03-31 11:54:22 +02:00
Unverified
parent 9d75bb43a3
commit 8ff63e158c
+11 -2
View File
@@ -5,6 +5,7 @@ using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Threading;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Caching;
@@ -452,6 +453,8 @@ namespace osu.Game.Screens.Ranking
public Action<UserTag>? OnSelected { get; set; }
private CancellationTokenSource? loadCancellationTokenSource;
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
@@ -502,8 +505,14 @@ namespace osu.Game.Screens.Ranking
AvailableTags.BindCollectionChanged((_, _) =>
{
searchContainer.Clear();
searchContainer.ChildrenEnumerable = createItems(AvailableTags.Values);
loadCancellationTokenSource?.Cancel();
loadCancellationTokenSource = new CancellationTokenSource();
LoadComponentsAsync(createItems(AvailableTags.Values), loaded =>
{
searchContainer.Clear();
searchContainer.AddRange(loaded);
}, loadCancellationTokenSource.Token);
}, true);
searchBox.Current.BindValueChanged(_ => searchContainer.SearchTerm = searchBox.Current.Value, true);
}