1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 10:33:30 +08:00

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

View File

@ -7,8 +7,8 @@ using osu.Framework.Graphics.Containers;
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 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks
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);