Fetch listing only once; Reenable disabled links as they wont be regenerated

This commit is contained in:
HoutarouOreki
2018-07-24 21:42:25 +02:00
parent 08a291f0d4
commit 43a7b3a825
2 changed files with 31 additions and 13 deletions

View File

@ -171,7 +171,13 @@ namespace osu.Game.Overlays.Changelog
Direction = FillDirection.Vertical, Direction = FillDirection.Vertical,
}, },
}; };
clickableText.Action += () => clickableText.IsEnabled = false;
// we may not want double clicks to make it double the work
clickableText.Action += () =>
{
clickableText.IsEnabled = false;
Scheduler.AddDelayed(() => clickableText.IsEnabled = true, 2000);
};
} }
public void UpdateChevronTooltips(string previousVersion, string nextVersion) public void UpdateChevronTooltips(string previousVersion, string nextVersion)

View File

@ -26,6 +26,7 @@ namespace osu.Game.Overlays
private readonly ChangelogHeader header; private readonly ChangelogHeader header;
private readonly ChangelogBadges badges; private readonly ChangelogBadges badges;
private readonly ChangelogChart chart; private readonly ChangelogChart chart;
private readonly ChangelogContent listing;
private readonly ChangelogContent content; private readonly ChangelogContent content;
private readonly ScrollContainer scroll; private readonly ScrollContainer scroll;
@ -85,13 +86,15 @@ namespace osu.Game.Overlays
header = new ChangelogHeader(), header = new ChangelogHeader(),
badges = new ChangelogBadges(), badges = new ChangelogBadges(),
chart = new ChangelogChart(), chart = new ChangelogChart(),
listing = new ChangelogContent(),
content = new ChangelogContent() content = new ChangelogContent()
}, },
}, },
}, },
}; };
header.ListingSelected += FetchAndShowListing; header.ListingSelected += ShowListing;
badges.Selected += onBuildSelected; badges.Selected += onBuildSelected;
listing.BuildSelected += onBuildSelected;
content.BuildSelected += onBuildSelected; content.BuildSelected += onBuildSelected;
} }
@ -107,7 +110,7 @@ namespace osu.Game.Overlays
var req = new GetChangelogLatestBuildsRequest(); var req = new GetChangelogLatestBuildsRequest();
req.Success += badges.Populate; req.Success += badges.Populate;
api.Queue(req); api.Queue(req);
FetchAndShowListing(); fetchListing();
base.LoadComplete(); base.LoadComplete();
} }
@ -132,7 +135,7 @@ namespace osu.Game.Overlays
State = Visibility.Hidden; State = Visibility.Hidden;
else else
{ {
FetchAndShowListing(); ShowListing();
sampleBack?.Play(); sampleBack?.Play();
} }
return true; return true;
@ -143,10 +146,7 @@ namespace osu.Game.Overlays
private void onBuildSelected(APIChangelog build, EventArgs e) => FetchAndShowBuild(build); private void onBuildSelected(APIChangelog build, EventArgs e) => FetchAndShowBuild(build);
/// <summary> private void fetchListing()
/// If we're not already at it, fetches and shows changelog listing.
/// </summary>
public void FetchAndShowListing()
{ {
header.ShowListing(); header.ShowListing();
if (isAtListing) if (isAtListing)
@ -155,14 +155,24 @@ namespace osu.Game.Overlays
var req = new GetChangelogRequest(); var req = new GetChangelogRequest();
badges.SelectNone(); badges.SelectNone();
chart.ShowAllUpdateStreams(); chart.ShowAllUpdateStreams();
req.Success += listing => req.Success += listing.ShowListing;
{
content.ShowListing(listing);
scroll.ScrollTo(savedScrollPosition);
};
api.Queue(req); api.Queue(req);
} }
public void ShowListing()
{
header.ShowListing();
if (isAtListing)
return;
isAtListing = true;
content.Hide();
listing.Show();
badges.SelectNone();
chart.ShowAllUpdateStreams();
listing.Show();
scroll.ScrollTo(savedScrollPosition);
}
/// <summary> /// <summary>
/// Fetches and shows a specific build from a specific update stream. /// Fetches and shows a specific build from a specific update stream.
/// </summary> /// </summary>
@ -181,6 +191,8 @@ namespace osu.Game.Overlays
chart.ShowUpdateStream(build.UpdateStream.Name); chart.ShowUpdateStream(build.UpdateStream.Name);
req.Success += APIChangelog => req.Success += APIChangelog =>
{ {
listing.Hide();
content.Show();
content.ShowBuild(APIChangelog); content.ShowBuild(APIChangelog);
if (scroll.Current > scroll.GetChildPosInContent(content)) if (scroll.Current > scroll.GetChildPosInContent(content))
scroll.ScrollTo(content); scroll.ScrollTo(content);