1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-13 05:22:54 +08:00

Make getDatabasedScoreInfo() private and move to GetScore() and Export()

This commit is contained in:
Joseph Madamba 2024-04-15 20:48:51 -07:00
parent 67cfcddc77
commit 514e316b49
3 changed files with 16 additions and 10 deletions

View File

@ -706,11 +706,9 @@ namespace osu.Game
{
Logger.Log($"Beginning {nameof(PresentScore)} with score {score}");
ScoreInfo databasedScoreInfo = ScoreManager.GetDatabasedScoreInfo(score);
var databasedScore = ScoreManager.GetScore(score);
if (databasedScoreInfo == null) return;
var databasedScore = ScoreManager.GetScore(databasedScoreInfo);
if (databasedScore == null) return;
if (databasedScore.Replay == null)
{

View File

@ -58,7 +58,12 @@ namespace osu.Game.Scoring
};
}
public Score GetScore(ScoreInfo score) => scoreImporter.GetScore(score);
public Score? GetScore(IScoreInfo scoreInfo)
{
ScoreInfo? databasedScoreInfo = getDatabasedScoreInfo(scoreInfo);
return databasedScoreInfo == null ? null : scoreImporter.GetScore(databasedScoreInfo);
}
/// <summary>
/// Perform a lookup query on available <see cref="ScoreInfo"/>s.
@ -76,7 +81,7 @@ namespace osu.Game.Scoring
/// <param name="originalScoreInfo">The <see cref="IScoreInfo"/> to attempt querying on.</param>
/// <returns>The databased score info. Null if the score on the database cannot be found.</returns>
/// <remarks>Can be used when the <see cref="IScoreInfo"/> was retrieved from online data, as it may have missing properties.</remarks>
public ScoreInfo? GetDatabasedScoreInfo(IScoreInfo originalScoreInfo)
private ScoreInfo? getDatabasedScoreInfo(IScoreInfo originalScoreInfo)
{
ScoreInfo? databasedScoreInfo = null;
@ -189,7 +194,12 @@ namespace osu.Game.Scoring
public Task<IEnumerable<Live<ScoreInfo>>> Import(ProgressNotification notification, ImportTask[] tasks, ImportParameters parameters = default) => scoreImporter.Import(notification, tasks);
public Task Export(ScoreInfo score) => scoreExporter.ExportAsync(score.ToLive(Realm));
public Task? Export(ScoreInfo scoreInfo)
{
ScoreInfo? databasedScoreInfo = getDatabasedScoreInfo(scoreInfo);
return databasedScoreInfo == null ? null : scoreExporter.ExportAsync(databasedScoreInfo.ToLive(Realm));
}
public Task<Live<ScoreInfo>?> ImportAsUpdate(ProgressNotification notification, ImportTask task, ScoreInfo original) => scoreImporter.ImportAsUpdate(notification, task, original);

View File

@ -147,9 +147,7 @@ namespace osu.Game.Screens.Ranking
{
if (state.NewValue != DownloadState.LocallyAvailable) return;
ScoreInfo? databasedScoreInfo = scoreManager.GetDatabasedScoreInfo(Score.Value);
if (databasedScoreInfo != null) scoreManager.Export(databasedScoreInfo);
scoreManager.Export(Score.Value);
State.ValueChanged -= exportWhenReady;
}