mirror of https://github.com/ppy/osu
Update save score button to check availability after import
Previously was relying on whether `SaveReplay` returns null, but since I've changed it to use the standard "prepare score for import" path, the button has to check for local availability after import since that path doesn't return null on fail.
This commit is contained in:
parent
6285442b7d
commit
e6236ba088
|
@ -55,7 +55,7 @@ private void load(OsuColour colours)
|
|||
Direction = FillDirection.Horizontal,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new SaveFailedScoreButton(() => SaveReplay())
|
||||
new SaveFailedScoreButton(SaveReplay)
|
||||
{
|
||||
Width = 300
|
||||
},
|
||||
|
|
|
@ -22,7 +22,7 @@ public class SaveFailedScoreButton : CompositeDrawable
|
|||
|
||||
private readonly Func<Task<ScoreInfo>> 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<ScoreInfo>(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<ScoreInfo>(player.Score.ScoreInfo.ID)?.Detach());
|
||||
if (score != null)
|
||||
importedScore = realm.Run(r => r.Find<ScoreInfo>(player.Score.ScoreInfo.ID)?.Detach());
|
||||
if (importedScore != null)
|
||||
state.Value = DownloadState.LocallyAvailable;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue