mirror of
https://github.com/ppy/osu.git
synced 2025-02-13 16:02:58 +08:00
Ensure Leaderboard.Scores
is updated immediately via request flow
This commit is contained in:
parent
1c02fa8399
commit
68c040175a
@ -185,14 +185,22 @@ namespace osu.Game.Online.Leaderboards
|
|||||||
if (scores != null)
|
if (scores != null)
|
||||||
this.scores.AddRange(scores);
|
this.scores.AddRange(scores);
|
||||||
|
|
||||||
userScoreContainer.Score.Value = userScore;
|
// Schedule needs to be non-delayed here for the weird logic in refetchScores to work.
|
||||||
|
// If it is removed, the placeholder will be incorrectly updated to "no scores" rather than "retrieving".
|
||||||
|
// This whole flow should be refactored in the future.
|
||||||
|
Scheduler.Add(applyNewScores, false);
|
||||||
|
|
||||||
if (userScore == null)
|
void applyNewScores()
|
||||||
userScoreContainer.Hide();
|
{
|
||||||
else
|
userScoreContainer.Score.Value = userScore;
|
||||||
userScoreContainer.Show();
|
|
||||||
|
|
||||||
Scheduler.Add(updateScoresDrawables, false);
|
if (userScore == null)
|
||||||
|
userScoreContainer.Hide();
|
||||||
|
else
|
||||||
|
userScoreContainer.Show();
|
||||||
|
|
||||||
|
updateScoresDrawables();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -212,8 +220,8 @@ namespace osu.Game.Online.Leaderboards
|
|||||||
Debug.Assert(ThreadSafety.IsUpdateThread);
|
Debug.Assert(ThreadSafety.IsUpdateThread);
|
||||||
|
|
||||||
cancelPendingWork();
|
cancelPendingWork();
|
||||||
SetScores(null);
|
|
||||||
|
|
||||||
|
SetScores(null);
|
||||||
setState(LeaderboardState.Retrieving);
|
setState(LeaderboardState.Retrieving);
|
||||||
|
|
||||||
currentFetchCancellationSource = new CancellationTokenSource();
|
currentFetchCancellationSource = new CancellationTokenSource();
|
||||||
|
@ -148,13 +148,10 @@ namespace osu.Game.Screens.Select.Leaderboards
|
|||||||
|
|
||||||
var req = new GetScoresRequest(fetchBeatmapInfo, fetchRuleset, Scope, requestMods);
|
var req = new GetScoresRequest(fetchBeatmapInfo, fetchRuleset, Scope, requestMods);
|
||||||
|
|
||||||
req.Success += r => Schedule(() =>
|
req.Success += r => SetScores(
|
||||||
{
|
scoreManager.OrderByTotalScore(r.Scores.Select(s => s.ToScoreInfo(rulesets, fetchBeatmapInfo))),
|
||||||
SetScores(
|
r.UserScore?.CreateScoreInfo(rulesets, fetchBeatmapInfo)
|
||||||
scoreManager.OrderByTotalScore(r.Scores.Select(s => s.ToScoreInfo(rulesets, fetchBeatmapInfo))),
|
);
|
||||||
r.UserScore?.CreateScoreInfo(rulesets, fetchBeatmapInfo)
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
return req;
|
return req;
|
||||||
}
|
}
|
||||||
@ -209,7 +206,7 @@ namespace osu.Game.Screens.Select.Leaderboards
|
|||||||
|
|
||||||
scores = scoreManager.OrderByTotalScore(scores.Detach());
|
scores = scoreManager.OrderByTotalScore(scores.Detach());
|
||||||
|
|
||||||
Schedule(() => SetScores(scores));
|
SetScores(scores);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user