Prepare changelog api requests to work when not logged in

This commit is contained in:
Dean Herbert 2019-05-23 11:38:13 +09:00
parent cb62008280
commit 5a887dabfe
2 changed files with 29 additions and 20 deletions

View File

@ -33,26 +33,31 @@ namespace osu.Game.Overlays.Changelog
[BackgroundDependencyLoader]
private void load(CancellationToken? cancellation, IAPIProvider api)
{
var req = new GetChangelogBuildRequest(build.UpdateStream.Name, build.Version);
bool complete = false;
var req = new GetChangelogBuildRequest(build.UpdateStream.Name, build.Version);
req.Success += res =>
{
build = res;
complete = true;
};
req.Failure += _ => complete = true;
api.Queue(req);
Task.Run(() => req.Perform(api));
while (!complete && cancellation?.IsCancellationRequested != true)
Task.Delay(1);
Children = new Drawable[]
while (!complete)
{
new ChangelogBuildWithNavigation(build) { SelectBuild = SelectBuild },
};
if (cancellation?.IsCancellationRequested == true)
{
req.Cancel();
return;
}
Task.Delay(1);
}
if (build != null)
Child = new ChangelogBuildWithNavigation(build) { SelectBuild = SelectBuild };
}
public class ChangelogBuildWithNavigation : ChangelogBuild

View File

@ -4,6 +4,7 @@
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using JetBrains.Annotations;
using osu.Framework.Allocation;
using osu.Framework.Audio;
@ -136,21 +137,24 @@ namespace osu.Game.Overlays
{
initialFetchPerformed = true;
var req = new GetChangelogRequest();
req.Success += res =>
Task.Run(() =>
{
// remap streams to builds to ensure model equality
res.Builds.ForEach(b => b.UpdateStream = res.Streams.Find(s => s.Id == b.UpdateStream.Id));
res.Streams.ForEach(s => s.LatestBuild.UpdateStream = res.Streams.Find(s2 => s2.Id == s.LatestBuild.UpdateStream.Id));
var req = new GetChangelogRequest();
req.Success += res =>
{
// remap streams to builds to ensure model equality
res.Builds.ForEach(b => b.UpdateStream = res.Streams.Find(s => s.Id == b.UpdateStream.Id));
res.Streams.ForEach(s => s.LatestBuild.UpdateStream = res.Streams.Find(s2 => s2.Id == s.LatestBuild.UpdateStream.Id));
builds = res.Builds;
header.Streams.Populate(res.Streams);
builds = res.Builds;
header.Streams.Populate(res.Streams);
Current.TriggerChange();
};
req.Failure += _ => initialFetchPerformed = false;
Current.TriggerChange();
};
req.Failure += _ => initialFetchPerformed = false;
API.Queue(req);
req.Perform(API);
});
}
private CancellationTokenSource loadContentTask;