Skip to content

Commit

Permalink
Unregister leaderboard if HitbloqLevelInfo returns error
Browse files Browse the repository at this point in the history
  • Loading branch information
Sirspam committed Aug 20, 2023
1 parent 1df2ae5 commit e670ad1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 3 additions & 0 deletions Hitbloq/Entries/HitbloqLevelInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ namespace Hitbloq.Entries
{
internal class HitbloqLevelInfo
{
[JsonProperty("error")]
public string? Error { get; private set; }

[JsonProperty("star_rating")]
public ReadOnlyDictionary<string, float> Pools { get; private set; } = null!;
}
Expand Down
7 changes: 6 additions & 1 deletion Hitbloq/Sources/LevelInfoSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public LevelInfoSource(IHttpService siraHttpService)
{
if (_cache.TryGetValue(difficultyBeatmap, out var cachedValue))
{
return cachedValue;
return cachedValue;
}

var beatmapString = Utils.DifficultyBeatmapToString(difficultyBeatmap);
Expand All @@ -36,6 +36,11 @@ public LevelInfoSource(IHttpService siraHttpService)
var webResponse = await _siraHttpService.GetAsync($"{PluginConfig.Instance.HitbloqURL}/api/leaderboard/{beatmapString}/info", cancellationToken: cancellationToken).ConfigureAwait(false);
var levelInfo = await Utils.ParseWebResponse<HitbloqLevelInfo>(webResponse);

if (levelInfo?.Error != null)
{
return null;
}

_cache[difficultyBeatmap] = levelInfo;
return levelInfo;
}
Expand Down

0 comments on commit e670ad1

Please sign in to comment.