Fix loading scores on profile pages potentially causing long blocking operations

This commit is contained in:
Dean Herbert 2018-12-03 18:37:44 +09:00
parent c227c06fa1
commit 7e35afd178
1 changed files with 20 additions and 19 deletions

View File

@ -7,8 +7,8 @@
using osu.Game.Online.API.Requests;
using osu.Game.Users;
using System;
using System.Collections.Generic;
using System.Linq;
using osu.Game.Online.API.Requests.Responses;
namespace osu.Game.Overlays.Profile.Sections.Ranks
{
@ -39,33 +39,34 @@ protected override void ShowMore()
foreach (var s in scores)
s.Ruleset = Rulesets.GetRuleset(s.RulesetID);
ShowMoreButton.FadeTo(scores.Count == ItemsPerPage ? 1 : 0);
ShowMoreLoading.Hide();
if (!scores.Any() && VisiblePages == 1)
{
ShowMoreButton.Hide();
ShowMoreLoading.Hide();
MissingText.Show();
return;
}
MissingText.Hide();
IEnumerable<DrawableProfileScore> drawableScores;
foreach (APIScoreInfo score in scores)
switch (type)
{
DrawableProfileScore drawableScore;
switch (type)
{
default:
drawableScore = new DrawablePerformanceScore(score, includeWeight ? Math.Pow(0.95, ItemsContainer.Count) : (double?)null);
break;
case ScoreType.Recent:
drawableScore = new DrawableTotalScore(score);
break;
}
ItemsContainer.Add(drawableScore);
default:
drawableScores = scores.Select(score => new DrawablePerformanceScore(score, includeWeight ? Math.Pow(0.95, ItemsContainer.Count) : (double?)null));
break;
case ScoreType.Recent:
drawableScores = scores.Select(score => new DrawableTotalScore(score));
break;
}
LoadComponentsAsync(drawableScores, s =>
{
MissingText.Hide();
ShowMoreButton.FadeTo(scores.Count == ItemsPerPage ? 1 : 0);
ShowMoreLoading.Hide();
ItemsContainer.AddRange(s);
});
});
Api.Queue(request);