diff --git a/Hitbloq/Other/LeaderboardRefresher.cs b/Hitbloq/Other/LeaderboardRefresher.cs index 6a27932..319c520 100644 --- a/Hitbloq/Other/LeaderboardRefresher.cs +++ b/Hitbloq/Other/LeaderboardRefresher.cs @@ -56,7 +56,7 @@ public async Task Refresh() } hitbloqPanelController.PromptText = "The action queue is very busy, your score cannot be refreshed for now."; } - else if (refreshEntry.error != null) + else if (refreshEntry != null && refreshEntry.error != null) { hitbloqPanelController.PromptText = $"Error: {refreshEntry.error}"; } diff --git a/Hitbloq/Sources/FriendLeaderboardSource.cs b/Hitbloq/Sources/FriendLeaderboardSource.cs index 128b81c..d8432a9 100644 --- a/Hitbloq/Sources/FriendLeaderboardSource.cs +++ b/Hitbloq/Sources/FriendLeaderboardSource.cs @@ -48,7 +48,7 @@ public async Task> GetScoresTask(IDifficultyBeatma HitbloqUserID userID = await userIDSource.GetUserIDAsync(cancellationToken); List friendIDs = await friendIDSource.GetFriendIDsAsync(cancellationToken); - if (userID.id == -1) + if (userID.id == -1 || friendIDs == null) { return null; } @@ -91,6 +91,12 @@ public async Task> GetScoresTask(IDifficultyBeatma } catch (TaskCanceledException) { } } + + if (cachedEntries == null) + { + return null; + } + return page < cachedEntries.Count ? cachedEntries[page] : null; } diff --git a/Hitbloq/UI/ViewControllers/HitbloqLeaderboardViewController.cs b/Hitbloq/UI/ViewControllers/HitbloqLeaderboardViewController.cs index 202e04d..f84f57e 100644 --- a/Hitbloq/UI/ViewControllers/HitbloqLeaderboardViewController.cs +++ b/Hitbloq/UI/ViewControllers/HitbloqLeaderboardViewController.cs @@ -150,9 +150,12 @@ public async void SetScores(List leaderboardEntries) scores.Add(new LeaderboardTableView.ScoreData(leaderboardEntries[i].score, $"{leaderboardEntries[i].username} - ({leaderboardEntries[i].accuracy.ToString("F2")}%) - ({leaderboardEntries[i].cr[selectedPool].ToString("F2")}cr)", leaderboardEntries[i].rank, false)); - infoButtons[i].gameObject.SetActive(true); - HoverHint hoverHint = infoButtons[i].GetComponent(); - hoverHint.text = $"Score Set: {leaderboardEntries[i].dateSet}"; + if (infoButtons != null) + { + infoButtons[i].gameObject.SetActive(true); + HoverHint hoverHint = infoButtons[i].GetComponent(); + hoverHint.text = $"Score Set: {leaderboardEntries[i].dateSet}"; + } if (leaderboardEntries[i].userID == id) { diff --git a/Hitbloq/UI/ViewControllers/HitbloqPanelController.cs b/Hitbloq/UI/ViewControllers/HitbloqPanelController.cs index 938d7a6..fd80b1e 100644 --- a/Hitbloq/UI/ViewControllers/HitbloqPanelController.cs +++ b/Hitbloq/UI/ViewControllers/HitbloqPanelController.cs @@ -106,13 +106,15 @@ private void Inject(MainFlowCoordinator mainFlowCoordinator, HitbloqFlowCoordina private async void PostParse() { // Backround related stuff - container.background.material = BeatSaberMarkupLanguage.Utilities.ImageResources.NoGlowMat; - ImageView background = container.background as ImageView; - background.color0 = Color.white; - background.color1 = new Color(1f, 1f, 1f, 0f); - background.color = Color.gray; - Accessors.GradientAccessor(ref background) = true; - Accessors.SkewAccessor(ref background) = 0.18f; + if (container.background is ImageView background) + { + background.material = BeatSaberMarkupLanguage.Utilities.ImageResources.NoGlowMat; + background.color0 = Color.white; + background.color1 = new Color(1f, 1f, 1f, 0f); + background.color = Color.gray; + Accessors.GradientAccessor(ref background) = true; + Accessors.SkewAccessor(ref background) = 0.18f; + } // Loading up logos logoSprite = logo.sprite; diff --git a/Hitbloq/UI/ViewControllers/HitbloqProfileModalController.cs b/Hitbloq/UI/ViewControllers/HitbloqProfileModalController.cs index 941e680..1b84fc1 100644 --- a/Hitbloq/UI/ViewControllers/HitbloqProfileModalController.cs +++ b/Hitbloq/UI/ViewControllers/HitbloqProfileModalController.cs @@ -181,8 +181,10 @@ private void PostParse() addFriend = BeatSaberMarkupLanguage.Utilities.FindSpriteInAssembly("Hitbloq.Images.AddFriend.png"); friendAdded = BeatSaberMarkupLanguage.Utilities.FindSpriteInAssembly("Hitbloq.Images.FriendAdded.png"); - ImageView verticalBackground = modalInfoVertical.background as ImageView; - verticalBackground.color = new Color(0f, 0f, 0f, 0.75f); + if (modalInfoVertical.background is ImageView verticalBackground) + { + verticalBackground.color = new Color(0f, 0f, 0f, 0.75f); + } } private void Parse(Transform parentTransform) diff --git a/Hitbloq/manifest.json b/Hitbloq/manifest.json index 4bc8b2c..b3e19cb 100644 --- a/Hitbloq/manifest.json +++ b/Hitbloq/manifest.json @@ -3,7 +3,7 @@ "id": "Hitbloq", "name": "Hitbloq", "author": "PauseChampions & DaFluffyPotato", - "version": "1.2.0", + "version": "1.2.1", "description": [ "#![Hitbloq.Description.md]", "Hitbloq offers a unique competitive experience for Beat Saber through its use of map pools and the relative ranking algorithm."