mirror of
https://github.com/ppy/osu.git
synced 2025-01-15 00:52:57 +08:00
Add debounce logic in several places
This commit is contained in:
parent
1b4bcb81c8
commit
10287eb66d
@ -9,6 +9,7 @@ using osu.Framework.Bindables;
|
||||
using osu.Framework.Extensions.IEnumerableExtensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Threading;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Online.Multiplayer;
|
||||
using osuTK;
|
||||
@ -62,7 +63,10 @@ namespace osu.Game.Screens.Multi.Lounge.Components
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
filter?.BindValueChanged(f => Filter(f.NewValue), true);
|
||||
filter?.BindValueChanged(f => scheduleFilter());
|
||||
|
||||
if (filter != null)
|
||||
Filter(filter.Value);
|
||||
}
|
||||
|
||||
public void Filter(FilterCriteria criteria)
|
||||
@ -89,6 +93,17 @@ namespace osu.Game.Screens.Multi.Lounge.Components
|
||||
});
|
||||
}
|
||||
|
||||
private ScheduledDelegate scheduledFilter;
|
||||
|
||||
private void scheduleFilter()
|
||||
{
|
||||
if (filter == null)
|
||||
return;
|
||||
|
||||
scheduledFilter?.Cancel();
|
||||
scheduledFilter = Scheduler.AddDelayed(() => Filter(filter.Value), 200);
|
||||
}
|
||||
|
||||
private void addRooms(IEnumerable<Room> rooms)
|
||||
{
|
||||
foreach (var r in rooms)
|
||||
|
@ -7,6 +7,7 @@ using System.Threading.Tasks;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Logging;
|
||||
using osu.Framework.Threading;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Online;
|
||||
using osu.Game.Online.API;
|
||||
@ -44,7 +45,7 @@ namespace osu.Game.Screens.Multi
|
||||
currentFilter.BindValueChanged(_ =>
|
||||
{
|
||||
if (IsLoaded)
|
||||
PollImmediately();
|
||||
schedulePoll();
|
||||
});
|
||||
}
|
||||
|
||||
@ -157,6 +158,14 @@ namespace osu.Game.Screens.Multi
|
||||
return tcs.Task;
|
||||
}
|
||||
|
||||
private ScheduledDelegate scheduledPoll;
|
||||
|
||||
private void schedulePoll()
|
||||
{
|
||||
scheduledPoll?.Cancel();
|
||||
scheduledPoll = Scheduler.AddDelayed(PollImmediately, 200);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates a local <see cref="Room"/> with a remote copy.
|
||||
/// </summary>
|
||||
|
Loading…
Reference in New Issue
Block a user