mirror of
https://github.com/osukey/osukey.git
synced 2025-05-22 14:07:38 +09:00
Don't use CancelDelayedTasks to avoid cancelling unwanted tasks
This commit is contained in:
parent
157502339e
commit
3227dc87fb
@ -17,6 +17,7 @@ using osu.Game.Overlays.Social;
|
|||||||
using osu.Game.Users;
|
using osu.Game.Users;
|
||||||
using System;
|
using System;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
using osu.Framework.Threading;
|
||||||
|
|
||||||
namespace osu.Game.Overlays
|
namespace osu.Game.Overlays
|
||||||
{
|
{
|
||||||
@ -77,12 +78,12 @@ namespace osu.Game.Overlays
|
|||||||
currentQuery.BindTo(Filter.Search.Current);
|
currentQuery.BindTo(Filter.Search.Current);
|
||||||
currentQuery.ValueChanged += query =>
|
currentQuery.ValueChanged += query =>
|
||||||
{
|
{
|
||||||
Scheduler.CancelDelayedTasks();
|
queryChangedDebounce?.Cancel();
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(query.NewValue))
|
if (string.IsNullOrEmpty(query.NewValue))
|
||||||
queueUpdate();
|
queueUpdate();
|
||||||
else
|
else
|
||||||
Scheduler.AddDelayed(updateSearch, 500);
|
queryChangedDebounce = Scheduler.AddDelayed(updateSearch, 500);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -90,13 +91,15 @@ namespace osu.Game.Overlays
|
|||||||
|
|
||||||
private readonly Bindable<string> currentQuery = new Bindable<string>();
|
private readonly Bindable<string> currentQuery = new Bindable<string>();
|
||||||
|
|
||||||
|
private ScheduledDelegate queryChangedDebounce;
|
||||||
|
|
||||||
private void queueUpdate() => Scheduler.AddOnce(updateSearch);
|
private void queueUpdate() => Scheduler.AddOnce(updateSearch);
|
||||||
|
|
||||||
private CancellationTokenSource loadCancellation;
|
private CancellationTokenSource loadCancellation;
|
||||||
|
|
||||||
private void updateSearch()
|
private void updateSearch()
|
||||||
{
|
{
|
||||||
Scheduler.CancelDelayedTasks();
|
queryChangedDebounce?.Cancel();
|
||||||
|
|
||||||
if (!IsLoaded)
|
if (!IsLoaded)
|
||||||
return;
|
return;
|
||||||
@ -169,6 +172,9 @@ namespace osu.Game.Overlays
|
|||||||
|
|
||||||
LoadComponentAsync(newPanels, f =>
|
LoadComponentAsync(newPanels, f =>
|
||||||
{
|
{
|
||||||
|
if (panels != null)
|
||||||
|
ScrollFlow.Remove(panels);
|
||||||
|
|
||||||
loading.Hide();
|
loading.Hide();
|
||||||
ScrollFlow.Add(panels = newPanels);
|
ScrollFlow.Add(panels = newPanels);
|
||||||
}, loadCancellation.Token);
|
}, loadCancellation.Token);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user