mirror of https://github.com/ppy/osu
Make operation run asynchronously
This commit is contained in:
parent
798bc1306b
commit
acc2113027
|
@ -8,20 +8,15 @@
|
|||
using osu.Game.Scoring;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace osu.Game.Screens.Select
|
||||
{
|
||||
public class BeatmapClearScoresDialog : PopupDialog
|
||||
{
|
||||
private ScoreManager manager;
|
||||
private ScoreManager scoreManager;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(ScoreManager scoreManager)
|
||||
{
|
||||
manager = scoreManager;
|
||||
}
|
||||
|
||||
public BeatmapClearScoresDialog(BeatmapInfo beatmap, Action refresh)
|
||||
public BeatmapClearScoresDialog(BeatmapInfo beatmap, Action onCompletion)
|
||||
{
|
||||
BodyText = $@"{beatmap.Metadata?.Artist} - {beatmap.Metadata?.Title}";
|
||||
Icon = FontAwesome.fa_eraser;
|
||||
|
@ -33,8 +28,8 @@ public BeatmapClearScoresDialog(BeatmapInfo beatmap, Action refresh)
|
|||
Text = @"Yes. Please.",
|
||||
Action = () =>
|
||||
{
|
||||
manager.Delete(manager.QueryScores(s => !s.DeletePending && s.Beatmap.ID == beatmap.ID).ToList());
|
||||
refresh();
|
||||
Task.Run(() => scoreManager.Delete(scoreManager.QueryScores(s => !s.DeletePending && s.Beatmap.ID == beatmap.ID).ToList()))
|
||||
.ContinueWith(t => Schedule(onCompletion));
|
||||
}
|
||||
},
|
||||
new PopupDialogCancelButton
|
||||
|
@ -43,5 +38,11 @@ public BeatmapClearScoresDialog(BeatmapInfo beatmap, Action refresh)
|
|||
},
|
||||
};
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(ScoreManager scoreManager)
|
||||
{
|
||||
this.scoreManager = scoreManager;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue