Skip to content

Commit

Permalink
fixed rides again and wh2 addons not appearing in downloadable list
Browse files Browse the repository at this point in the history
  • Loading branch information
fgsfds committed Nov 25, 2024
1 parent 3395720 commit dd0061b
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions src/Common.Client/Api/GitHubApiInterface.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -16,6 +17,7 @@ public sealed class GitHubApiInterface : IApiInterface
private readonly IRetriever<Dictionary<PortEnum, GeneralReleaseEntity>?> _portsReleasesRetriever;
private readonly RepoAppReleasesRetriever _appReleasesProvider;
private readonly HttpClient _httpClient;
private readonly ILogger _logger;
private readonly SemaphoreSlim _semaphore = new(1);

private Dictionary<GameEnum, List<DownloadableAddonEntity>>? _addonsJson = null;
Expand All @@ -24,12 +26,14 @@ public sealed class GitHubApiInterface : IApiInterface
public GitHubApiInterface(
IRetriever<Dictionary<PortEnum, GeneralReleaseEntity>?> portsReleasesProvider,
RepoAppReleasesRetriever appReleasesProvider,
HttpClient httpClient
HttpClient httpClient,
ILogger logger
)
{
_portsReleasesRetriever = portsReleasesProvider;
_appReleasesProvider = appReleasesProvider;
_httpClient = httpClient;
_logger = logger;
}


Expand Down Expand Up @@ -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
Expand Down

0 comments on commit dd0061b

Please sign in to comment.