From 4269cb7124804eae7364a6efccf0f33c2265912d Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 25 Mar 2021 13:48:41 +0900 Subject: [PATCH] Extract majority of token retrieval code out of LoadComponentAsync for legibility --- osu.Game/Screens/Play/SubmittingPlayer.cs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/osu.Game/Screens/Play/SubmittingPlayer.cs b/osu.Game/Screens/Play/SubmittingPlayer.cs index 87a4eb5efe..d22199447d 100644 --- a/osu.Game/Screens/Play/SubmittingPlayer.cs +++ b/osu.Game/Screens/Play/SubmittingPlayer.cs @@ -32,6 +32,13 @@ namespace osu.Game.Screens.Play } protected override void LoadAsyncComplete() + { + if (!handleTokenRetrieval()) return; + + base.LoadAsyncComplete(); + } + + private bool handleTokenRetrieval() { // Token request construction should happen post-load to allow derived classes to potentially prepare DI backings that are used to create the request. var tcs = new TaskCompletionSource(); @@ -39,7 +46,7 @@ namespace osu.Game.Screens.Play if (!api.IsLoggedIn) { handleTokenFailure(new InvalidOperationException("API is not online.")); - return; + return false; } var req = CreateTokenRequest(); @@ -47,7 +54,7 @@ namespace osu.Game.Screens.Play if (req == null) { handleTokenFailure(new InvalidOperationException("Request could not be constructed.")); - return; + return false; } req.Success += r => @@ -60,8 +67,7 @@ namespace osu.Game.Screens.Play api.Queue(req); tcs.Task.Wait(); - - base.LoadAsyncComplete(); + return true; void handleTokenFailure(Exception exception) {