From dd0061bb4e4e77816f53de8befddc2db84f18743 Mon Sep 17 00:00:00 2001 From: fgsfds <4870330+fgsfds@users.noreply.github.com> Date: Mon, 25 Nov 2024 11:36:47 +0500 Subject: [PATCH] fixed rides again and wh2 addons not appearing in downloadable list --- src/Common.Client/Api/GitHubApiInterface.cs | 25 +++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/src/Common.Client/Api/GitHubApiInterface.cs b/src/Common.Client/Api/GitHubApiInterface.cs index 61f5a5c..da23038 100644 --- a/src/Common.Client/Api/GitHubApiInterface.cs +++ b/src/Common.Client/Api/GitHubApiInterface.cs @@ -7,6 +7,7 @@ using Common.Enums; using Common.Helpers; using CommunityToolkit.Diagnostics; +using Microsoft.Extensions.Logging; using System.Text.Json; namespace Common.Client.Api; @@ -16,6 +17,7 @@ public sealed class GitHubApiInterface : IApiInterface private readonly IRetriever?> _portsReleasesRetriever; private readonly RepoAppReleasesRetriever _appReleasesProvider; private readonly HttpClient _httpClient; + private readonly ILogger _logger; private readonly SemaphoreSlim _semaphore = new(1); private Dictionary>? _addonsJson = null; @@ -24,12 +26,14 @@ public sealed class GitHubApiInterface : IApiInterface public GitHubApiInterface( IRetriever?> portsReleasesProvider, RepoAppReleasesRetriever appReleasesProvider, - HttpClient httpClient + HttpClient httpClient, + ILogger logger ) { _portsReleasesRetriever = portsReleasesProvider; _appReleasesProvider = appReleasesProvider; _httpClient = httpClient; + _logger = logger; } @@ -60,10 +64,27 @@ HttpClient httpClient } } + if (gameEnum is GameEnum.Redneck) + { + _ = _addonsJson.TryGetValue(GameEnum.Redneck, out var rrAddons); + _ = _addonsJson.TryGetValue(GameEnum.RidesAgain, out var againAddons); + + return [..rrAddons ?? [], ..againAddons ?? []]; + } + + if (gameEnum is GameEnum.Witchaven) + { + _ = _addonsJson.TryGetValue(GameEnum.Witchaven, out var w1Addons); + _ = _addonsJson.TryGetValue(GameEnum.Witchaven2, out var w2Addons); + + return [..w1Addons ?? [], ..w2Addons ?? []]; + } + return _addonsJson.TryGetValue(gameEnum, out var result) ? result : null; } - catch + catch (Exception ex) { + _logger.LogCritical(ex, "=== Error while getting addons from GitHub ==="); return []; } finally