mirror of https://github.com/ppy/osu
Use CancellationTokenSource to avoid unwanted panels creation
This commit is contained in:
parent
9b1e8cf48b
commit
2d7024ffd9
|
@ -17,6 +17,7 @@
|
|||
using osu.Game.Users;
|
||||
using osu.Framework.Threading;
|
||||
using System;
|
||||
using System.Threading;
|
||||
|
||||
namespace osu.Game.Overlays
|
||||
{
|
||||
|
@ -92,6 +93,8 @@ public SocialOverlay()
|
|||
|
||||
private void queueUpdate() => Scheduler.AddOnce(updateSearch);
|
||||
|
||||
private CancellationTokenSource loadCancellation;
|
||||
|
||||
private void updateSearch()
|
||||
{
|
||||
Scheduler.CancelDelayedTasks();
|
||||
|
@ -132,6 +135,8 @@ private void recreatePanels(PanelDisplayStyle displayStyle)
|
|||
return;
|
||||
}
|
||||
|
||||
loadCancellation = new CancellationTokenSource();
|
||||
|
||||
var newPanels = new FillFlowContainer<SocialPanel>
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
|
@ -167,7 +172,7 @@ private void recreatePanels(PanelDisplayStyle displayStyle)
|
|||
{
|
||||
loading.Hide();
|
||||
ScrollFlow.Add(panels = newPanels);
|
||||
});
|
||||
}, loadCancellation.Token);
|
||||
}
|
||||
|
||||
private void updateUsers(IEnumerable<User> newUsers)
|
||||
|
@ -212,6 +217,8 @@ private void clearPanels()
|
|||
{
|
||||
loading.Show();
|
||||
|
||||
loadCancellation?.Cancel();
|
||||
|
||||
if (panels != null)
|
||||
{
|
||||
panels.Expire();
|
||||
|
|
Loading…
Reference in New Issue