diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index 94678a9dde..78c6fa052b 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -506,22 +506,24 @@ namespace osu.Game // we could avoid the need for scheduling altogether. Schedule(() => { - if (asyncLoadStream != null) + var previousLoadStream = asyncLoadStream; + + //chain with existing load stream + asyncLoadStream = Task.Run(async () => { - //chain with existing load stream - asyncLoadStream = asyncLoadStream.ContinueWith(async t => + if (previousLoadStream != null) + await previousLoadStream; + + try { - try - { - await LoadComponentAsync(d, add); - } - catch (OperationCanceledException) - { - } - }); - } - else - asyncLoadStream = LoadComponentAsync(d, add); + Logger.Log($"Loading {d}...", LoggingTarget.Debug); + await LoadComponentAsync(d, add); + Logger.Log($"Loaded {d}!", LoggingTarget.Debug); + } + catch (OperationCanceledException) + { + } + }); }); } diff --git a/osu.Game/Overlays/DirectOverlay.cs b/osu.Game/Overlays/DirectOverlay.cs index 423211659d..f63d314053 100644 --- a/osu.Game/Overlays/DirectOverlay.cs +++ b/osu.Game/Overlays/DirectOverlay.cs @@ -240,6 +240,15 @@ namespace osu.Game.Overlays }); } + protected override void PopIn() + { + base.PopIn(); + + // Queries are allowed to be run only on the first pop-in + if (getSetsRequest == null) + Scheduler.AddOnce(updateSearch); + } + private SearchBeatmapSetsRequest getSetsRequest; private readonly Bindable currentQuery = new Bindable(); @@ -251,16 +260,22 @@ namespace osu.Game.Overlays { queryChangedDebounce?.Cancel(); - if (!IsLoaded) return; + if (!IsLoaded) + return; + + if (State == Visibility.Hidden) + return; BeatmapSets = null; ResultAmounts = null; getSetsRequest?.Cancel(); - if (api == null) return; + if (api == null) + return; - if (Header.Tabs.Current.Value == DirectTab.Search && (Filter.Search.Text == string.Empty || currentQuery == string.Empty)) return; + if (Header.Tabs.Current.Value == DirectTab.Search && (Filter.Search.Text == string.Empty || currentQuery == string.Empty)) + return; previewTrackManager.StopAnyPlaying(this);