From a38e25115bb03dfdd7311354254bf8dfede9b178 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Thu, 12 Jun 2025 10:33:42 +0200 Subject: [PATCH] Pick better initial beatmap status when submitting Addresses https://github.com/ppy/osu/discussions/33291 This is a half-baked RFC because things are awkward. For this to work correctly the submission flow has to do an API request, because one, the local beatmap status has been overwritten with "locally modified", and secondly, even if it *was* there, there's no guarantee that it was actually *up to date*. And if we have to do an API request then there are two choices: - Hard block on the API request and don't show anything until it completes which possibly means waiting at a spinner for several seconds if someone's on bad internet. - Don't block on the API request --- but then there's no guarantee what timing the API request completes at, which means that possibly the user could change the dropdown before the API request completes, and the API request will overwrite their choice, so to prevent that block the dropdown until the request completes. This is what this commit does. --- .../Submission/BeatmapSubmissionScreen.cs | 7 +++++ .../Submission/BeatmapSubmissionSettings.cs | 2 ++ .../Submission/ScreenSubmissionSettings.cs | 27 ++++++++++++++++++- 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/osu.Game/Screens/Edit/Submission/BeatmapSubmissionScreen.cs b/osu.Game/Screens/Edit/Submission/BeatmapSubmissionScreen.cs index 3a9eb2c1b0..03ab23d8e4 100644 --- a/osu.Game/Screens/Edit/Submission/BeatmapSubmissionScreen.cs +++ b/osu.Game/Screens/Edit/Submission/BeatmapSubmissionScreen.cs @@ -191,6 +191,13 @@ namespace osu.Game.Screens.Edit.Submission }); completedSample = audio.Samples.Get(@"UI/bss-complete"); + + if (Beatmap.Value.BeatmapSetInfo.OnlineID > 0) + { + var req = new GetBeatmapSetRequest(Beatmap.Value.BeatmapSetInfo.OnlineID); + api.Queue(req); + settings.LatestOnlineStateRequest = req; + } } private void createBeatmapSet() diff --git a/osu.Game/Screens/Edit/Submission/BeatmapSubmissionSettings.cs b/osu.Game/Screens/Edit/Submission/BeatmapSubmissionSettings.cs index 8cccc339a6..a1f3861d29 100644 --- a/osu.Game/Screens/Edit/Submission/BeatmapSubmissionSettings.cs +++ b/osu.Game/Screens/Edit/Submission/BeatmapSubmissionSettings.cs @@ -8,6 +8,8 @@ namespace osu.Game.Screens.Edit.Submission { public class BeatmapSubmissionSettings { + public GetBeatmapSetRequest? LatestOnlineStateRequest { get; set; } + public Bindable Target { get; } = new Bindable(); public Bindable NotifyOnDiscussionReplies { get; } = new Bindable(); diff --git a/osu.Game/Screens/Edit/Submission/ScreenSubmissionSettings.cs b/osu.Game/Screens/Edit/Submission/ScreenSubmissionSettings.cs index 969105b5c6..7b80fdee7d 100644 --- a/osu.Game/Screens/Edit/Submission/ScreenSubmissionSettings.cs +++ b/osu.Game/Screens/Edit/Submission/ScreenSubmissionSettings.cs @@ -1,16 +1,19 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using System.Diagnostics; using osu.Framework.Allocation; using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Localisation; +using osu.Game.Beatmaps; using osu.Game.Configuration; using osu.Game.Graphics; using osu.Game.Graphics.Containers; using osu.Game.Graphics.UserInterfaceV2; using osu.Game.Localisation; +using osu.Game.Online.API; using osu.Game.Online.API.Requests; using osu.Game.Overlays; using osuTK; @@ -25,8 +28,11 @@ namespace osu.Game.Screens.Edit.Submission public override LocalisableString? NextStepText => BeatmapSubmissionStrings.ConfirmSubmission; + [Resolved] + private BeatmapSubmissionSettings settings { get; set; } = null!; + [BackgroundDependencyLoader] - private void load(OsuConfigManager configManager, OsuColour colours, BeatmapSubmissionSettings settings) + private void load(OsuConfigManager configManager, OsuColour colours) { configManager.BindWith(OsuSetting.EditorSubmissionNotifyOnDiscussionReplies, settings.NotifyOnDiscussionReplies); configManager.BindWith(OsuSetting.EditorSubmissionLoadInBrowserAfterSubmission, loadInBrowserAfterSubmission); @@ -63,6 +69,25 @@ namespace osu.Game.Screens.Edit.Submission }, } }); + + switch (settings.LatestOnlineStateRequest?.CompletionState) + { + case APIRequestCompletionState.Completed: + setSubmissionTargetFromLatestOnlineState(); + break; + + case APIRequestCompletionState.Waiting: + settings.Target.Disabled = true; + settings.LatestOnlineStateRequest.Success += _ => setSubmissionTargetFromLatestOnlineState(); + break; + } + } + + private void setSubmissionTargetFromLatestOnlineState() + { + Debug.Assert(settings.LatestOnlineStateRequest != null); + settings.Target.Disabled = false; + settings.Target.Value = settings.LatestOnlineStateRequest.Response?.Status >= BeatmapOnlineStatus.Pending ? BeatmapSubmissionTarget.Pending : BeatmapSubmissionTarget.WIP; } } }