From 1bdd054bd60a6af5c0816cbbacf6ca629c771b8a Mon Sep 17 00:00:00 2001 From: cdwcgt Date: Wed, 2 Aug 2023 18:15:58 +0900 Subject: [PATCH] extract method --- .../Import/ReplayMissingBeatmapScreen.cs | 29 ++++++++++++++----- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/osu.Game/Screens/Import/ReplayMissingBeatmapScreen.cs b/osu.Game/Screens/Import/ReplayMissingBeatmapScreen.cs index a6215165fb..5707721bde 100644 --- a/osu.Game/Screens/Import/ReplayMissingBeatmapScreen.cs +++ b/osu.Game/Screens/Import/ReplayMissingBeatmapScreen.cs @@ -64,6 +64,8 @@ namespace osu.Game.Screens.Import public ReplayMissingBeatmapScreen(APIBeatmap beatmap, MemoryStream? scoreStream = null) { this.beatmap = beatmap; + beatmapSetInfo = beatmap.BeatmapSet; + this.scoreStream = scoreStream; } @@ -145,21 +147,32 @@ namespace osu.Game.Screens.Import { base.LoadComplete(); - var onlineBeatmapRequest = new GetBeatmapSetRequest(beatmap.OnlineBeatmapSetID); - - onlineBeatmapRequest.Success += res => + if (beatmapSetInfo == null) { - beatmapSetInfo = res; - beatmapPanelContainer.Child = new BeatmapCardNormal(res, allowExpansion: false); - checkForAutomaticDownload(res); - }; + var onlineBeatmapRequest = new GetBeatmapSetRequest(beatmap.OnlineBeatmapSetID); - api.Queue(onlineBeatmapRequest); + onlineBeatmapRequest.Success += res => + { + beatmapSetInfo = res; + updateStatus(); + }; + api.Queue(onlineBeatmapRequest); + } + updateStatus(); realmSubscription = realm.RegisterForNotifications( realm => realm.All().Where(s => !s.DeletePending), beatmapsChanged); } + private void updateStatus() + { + if (beatmapSetInfo == null) return; + + beatmapPanelContainer.Clear(); + beatmapPanelContainer.Child = new BeatmapCardNormal(beatmapSetInfo, allowExpansion: false); + checkForAutomaticDownload(beatmapSetInfo); + } + private void checkForAutomaticDownload(APIBeatmapSet beatmap) { if (!automaticDownload.Current.Value)