mirror of
https://github.com/ppy/osu
synced 2025-01-05 05:39:49 +00:00
Prepare changelog api requests to work when not logged in
This commit is contained in:
parent
cb62008280
commit
5a887dabfe
@ -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
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user