Fix incorrect propagation of stream/build on initial display with build

This commit is contained in:
Dean Herbert 2020-01-27 14:52:21 +09:00
parent 834e82d543
commit 292a82ac27
3 changed files with 19 additions and 6 deletions

View File

@ -2,6 +2,7 @@
// See the LICENCE file in the repository root for full licence text.
using System;
using System.Collections.Generic;
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
@ -37,7 +38,7 @@ public ChangelogHeader()
Streams.Current.ValueChanged += e =>
{
if (e.NewValue?.LatestBuild != null && e.NewValue != Current.Value?.UpdateStream)
if (e.NewValue?.LatestBuild != null && !e.NewValue.Equals(Current.Value?.UpdateStream))
Current.Value = e.NewValue.LatestBuild;
};
}
@ -54,7 +55,7 @@ private void showBuild(ValueChangedEvent<APIChangelogBuild> e)
BreadcrumbControl.AddItem(e.NewValue.ToString());
BreadcrumbControl.Current.Value = e.NewValue.ToString();
Streams.Current.Value = Streams.Items.FirstOrDefault(s => s.Name == e.NewValue.UpdateStream.Name);
updateCurrentStream();
title.Version = e.NewValue.UpdateStream.DisplayName;
}
@ -80,6 +81,20 @@ private void showBuild(ValueChangedEvent<APIChangelogBuild> e)
protected override ScreenTitle CreateTitle() => title = new ChangelogHeaderTitle();
public void Populate(List<APIUpdateStream> streams)
{
Streams.Populate(streams);
updateCurrentStream();
}
private void updateCurrentStream()
{
if (Current.Value == null)
return;
Streams.Current.Value = Streams.Items.FirstOrDefault(s => s.Name == Current.Value.UpdateStream.Name);
}
public class HeaderBackground : Sprite
{
public HeaderBackground()

View File

@ -29,8 +29,6 @@ public UpdateStreamBadgeArea()
public void Populate(List<APIUpdateStream> streams)
{
Current.Value = null;
foreach (APIUpdateStream updateStream in streams)
AddItem(updateStream);
}

View File

@ -1,4 +1,4 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using System;
@ -181,7 +181,7 @@ private Task fetchListing()
builds = res.Builds;
Streams = res.Streams;
Header.Streams.Populate(res.Streams);
Header.Populate(res.Streams);
tcs.SetResult(true);
});