diff --git a/osu.Game/Screens/Play/FailOverlay.cs b/osu.Game/Screens/Play/FailOverlay.cs index 76cd030a8f..2af5102369 100644 --- a/osu.Game/Screens/Play/FailOverlay.cs +++ b/osu.Game/Screens/Play/FailOverlay.cs @@ -55,7 +55,7 @@ private void load(OsuColour colours) Direction = FillDirection.Horizontal, Children = new Drawable[] { - new SaveFailedScoreButton(() => SaveReplay()) + new SaveFailedScoreButton(SaveReplay) { Width = 300 }, diff --git a/osu.Game/Screens/Play/SaveFailedScoreButton.cs b/osu.Game/Screens/Play/SaveFailedScoreButton.cs index 7eed2086ae..3f6e741dff 100644 --- a/osu.Game/Screens/Play/SaveFailedScoreButton.cs +++ b/osu.Game/Screens/Play/SaveFailedScoreButton.cs @@ -22,7 +22,7 @@ public class SaveFailedScoreButton : CompositeDrawable private readonly Func> importFailedScore; - private ScoreInfo? score; + private ScoreInfo? importedScore; private DownloadButton button = null!; @@ -45,17 +45,16 @@ private void load(OsuGame? game, Player? player, RealmAccess realm) switch (state.Value) { case DownloadState.LocallyAvailable: - game?.PresentScore(score, ScorePresentType.Gameplay); + game?.PresentScore(importedScore, ScorePresentType.Gameplay); break; case DownloadState.NotDownloaded: state.Value = DownloadState.Importing; - - Task.Run(importFailedScore).ContinueWith(result => Schedule(() => + Task.Run(importFailedScore).ContinueWith(t => { - score = result.GetResultSafely(); - state.Value = score != null ? DownloadState.LocallyAvailable : DownloadState.NotDownloaded; - })); + importedScore = realm.Run(r => r.Find(t.GetResultSafely().ID)?.Detach()); + Schedule(() => state.Value = importedScore != null ? DownloadState.LocallyAvailable : DownloadState.NotDownloaded); + }); break; } } @@ -63,8 +62,8 @@ private void load(OsuGame? game, Player? player, RealmAccess realm) if (player != null) { - score = realm.Run(r => r.Find(player.Score.ScoreInfo.ID)?.Detach()); - if (score != null) + importedScore = realm.Run(r => r.Find(player.Score.ScoreInfo.ID)?.Detach()); + if (importedScore != null) state.Value = DownloadState.LocallyAvailable; }