From dc44734db20e25c4a39b52faa4df0ff62740ee21 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 29 Oct 2021 11:56:17 +0900 Subject: [PATCH] Simplify null check in `ScoreDownloadTracker` and remove unnecessary ID check --- osu.Game/Online/ScoreDownloadTracker.cs | 26 ++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/osu.Game/Online/ScoreDownloadTracker.cs b/osu.Game/Online/ScoreDownloadTracker.cs index ac700fc587..8222a5382c 100644 --- a/osu.Game/Online/ScoreDownloadTracker.cs +++ b/osu.Game/Online/ScoreDownloadTracker.cs @@ -31,25 +31,25 @@ public ScoreDownloadTracker(ScoreInfo trackedItem) [BackgroundDependencyLoader(true)] private void load() { + if (Manager == null) + return; + // Used to interact with manager classes that don't support interface types. Will eventually be replaced. var scoreInfo = new ScoreInfo { OnlineScoreID = TrackedItem.OnlineScoreID }; - if (TrackedItem.ID > 0 || Manager?.IsAvailableLocally(scoreInfo) == true) + if (Manager.IsAvailableLocally(scoreInfo)) UpdateState(DownloadState.LocallyAvailable); - else if (Manager != null) + else attachDownload(Manager.GetExistingDownload(scoreInfo)); - if (Manager != null) - { - managerDownloadBegan = Manager.DownloadBegan.GetBoundCopy(); - managerDownloadBegan.BindValueChanged(downloadBegan); - managerDownloadFailed = Manager.DownloadFailed.GetBoundCopy(); - managerDownloadFailed.BindValueChanged(downloadFailed); - managerUpdated = Manager.ItemUpdated.GetBoundCopy(); - managerUpdated.BindValueChanged(itemUpdated); - managerRemoved = Manager.ItemRemoved.GetBoundCopy(); - managerRemoved.BindValueChanged(itemRemoved); - } + managerDownloadBegan = Manager.DownloadBegan.GetBoundCopy(); + managerDownloadBegan.BindValueChanged(downloadBegan); + managerDownloadFailed = Manager.DownloadFailed.GetBoundCopy(); + managerDownloadFailed.BindValueChanged(downloadFailed); + managerUpdated = Manager.ItemUpdated.GetBoundCopy(); + managerUpdated.BindValueChanged(itemUpdated); + managerRemoved = Manager.ItemRemoved.GetBoundCopy(); + managerRemoved.BindValueChanged(itemRemoved); } private void downloadBegan(ValueChangedEvent>> weakRequest)