Define local current bindable to bind value change instead

This commit is contained in:
Salman Ahmed 2021-11-05 18:07:12 +03:00
parent f013a1e37f
commit 51e7b9950e

View File

@ -26,6 +26,8 @@ namespace osu.Game.Overlays.Changelog
public static LocalisableString ListingString => LayoutStrings.HeaderChangelogIndex; public static LocalisableString ListingString => LayoutStrings.HeaderChangelogIndex;
private readonly Bindable<APIUpdateStream> currentStream = new Bindable<APIUpdateStream>();
private Box streamsBackground; private Box streamsBackground;
public ChangelogHeader() public ChangelogHeader()
@ -38,6 +40,12 @@ namespace osu.Game.Overlays.Changelog
}; };
Build.ValueChanged += showBuild; Build.ValueChanged += showBuild;
currentStream.ValueChanged += e =>
{
if (e.NewValue?.LatestBuild != null && !e.NewValue.Equals(Build.Value?.UpdateStream))
Build.Value = e.NewValue.LatestBuild;
};
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
@ -61,7 +69,7 @@ namespace osu.Game.Overlays.Changelog
else else
{ {
Current.Value = ListingString; Current.Value = ListingString;
Streams.Current.Value = null; currentStream.Value = null;
} }
} }
@ -88,17 +96,11 @@ namespace osu.Game.Overlays.Changelog
Horizontal = 65, Horizontal = 65,
Vertical = 20 Vertical = 20
}, },
Child = Streams = new ChangelogUpdateStreamControl() Child = Streams = new ChangelogUpdateStreamControl { Current = currentStream },
} }
} }
}; };
Streams.Current.ValueChanged += e =>
{
if (e.NewValue?.LatestBuild != null && !e.NewValue.Equals(Build.Value?.UpdateStream))
Build.Value = e.NewValue.LatestBuild;
};
return content; return content;
} }
@ -115,7 +117,7 @@ namespace osu.Game.Overlays.Changelog
if (Build.Value == null) if (Build.Value == null)
return; return;
Streams.Current.Value = Streams.Items.FirstOrDefault(s => s.Name == Build.Value.UpdateStream.Name); currentStream.Value = Streams.Items.FirstOrDefault(s => s.Name == Build.Value.UpdateStream.Name);
} }
private class ChangelogHeaderTitle : OverlayTitle private class ChangelogHeaderTitle : OverlayTitle