From 327bc708d7ed5a12cdafbdae4aa7a662523ae097 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Wed, 29 Aug 2018 15:56:24 +0900 Subject: [PATCH] Fix DirectOverlay performing webrequests on startup --- osu.Game/Overlays/DirectOverlay.cs | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) 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 @@ private void recreatePanels(PanelDisplayStyle displayStyle) }); } + 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 @@ private void updateSearch() { 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);