From 449b9a21aefe912280728fd621fe11c782fbdb28 Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Thu, 17 Dec 2020 13:31:57 +0300 Subject: [PATCH] Allow OverlayView fetching with no API requests required --- osu.Game/Overlays/OverlayView.cs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/osu.Game/Overlays/OverlayView.cs b/osu.Game/Overlays/OverlayView.cs index c254cdf290..f5ef183bd5 100644 --- a/osu.Game/Overlays/OverlayView.cs +++ b/osu.Game/Overlays/OverlayView.cs @@ -42,25 +42,29 @@ namespace osu.Game.Overlays /// /// Create the API request for fetching data. /// - protected abstract APIRequest CreateRequest(); + protected virtual APIRequest CreateRequest() => null; /// /// Fired when results arrive from the main API request. /// /// - protected abstract void OnSuccess(T response); + protected virtual void OnSuccess(T response) + { + } /// /// Force a re-request for data from the API. /// - protected void PerformFetch() + protected virtual void PerformFetch() { request?.Cancel(); - request = CreateRequest(); - request.Success += response => Schedule(() => OnSuccess(response)); - API.Queue(request); + if (request != null) + { + request.Success += response => Schedule(() => OnSuccess(response)); + API.Queue(request); + } } private void onlineStateChanged(ValueChangedEvent state) => Schedule(() =>