1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-14 00:53:19 +08:00

Fix panel expanded state being updated multiple times unnecessarily

This commit is contained in:
Dean Herbert 2020-10-29 17:03:45 +09:00
parent 71e373ff51
commit 11f85779d5

View File

@ -119,7 +119,10 @@ namespace osu.Game.Screens.Ranking
}));
if (SelectedScore.Value == score)
selectedScoreChanged(new ValueChangedEvent<ScoreInfo>(SelectedScore.Value, SelectedScore.Value));
{
if (IsLoaded)
SelectedScore.TriggerChange();
}
else
{
// We want the scroll position to remain relative to the expanded panel. When a new panel is added after the expanded panel, nothing needs to be done.
@ -142,6 +145,9 @@ namespace osu.Game.Screens.Ranking
/// </summary>
/// <param name="score">The <see cref="ScoreInfo"/> to present.</param>
private void selectedScoreChanged(ValueChangedEvent<ScoreInfo> score)
{
// avoid contracting panels unnecessarily when TriggerChange is fired manually.
if (score.OldValue != score.NewValue)
{
// Contract the old panel.
foreach (var t in flow.Where(t => t.Panel.Score == score.OldValue))
@ -149,6 +155,7 @@ namespace osu.Game.Screens.Ranking
t.Panel.State = PanelState.Contracted;
t.Margin = new MarginPadding();
}
}
// Find the panel corresponding to the new score.
var expandedTrackingComponent = flow.SingleOrDefault(t => t.Panel.Score == score.NewValue);