Check the featured_lists.json when loading modlists data

This commit is contained in:
Timothy Baldridge 2022-05-14 23:19:20 -06:00
parent 0626fd2899
commit 7ef7a2ae27
2 changed files with 13 additions and 3 deletions

View File

@ -7,7 +7,7 @@ on:
branches: [ main ] branches: [ main ]
env: env:
VERSION: 3.0.0.1 VERSION: 3.0.0.2
jobs: jobs:
build: build:

View File

@ -189,19 +189,29 @@ public class Client
public async Task<ModlistMetadata[]> LoadLists() public async Task<ModlistMetadata[]> LoadLists()
{ {
var repos = await LoadRepositories(); var repos = LoadRepositories();
var featured = await LoadFeaturedLists();
return await repos.PMapAll(async url => return await (await repos).PMapAll(async url =>
(await _client.GetFromJsonAsync<ModlistMetadata[]>(_limiter, new HttpRequestMessage(HttpMethod.Get, url.Value), (await _client.GetFromJsonAsync<ModlistMetadata[]>(_limiter, new HttpRequestMessage(HttpMethod.Get, url.Value),
_dtos.Options))!.Select(meta => _dtos.Options))!.Select(meta =>
{ {
meta.RepositoryName = url.Key; meta.RepositoryName = url.Key;
meta.Official = (meta.RepositoryName == "wj-featured" || featured.Contains(meta.NamespacedName));
return meta; return meta;
})) }))
.SelectMany(x => x) .SelectMany(x => x)
.ToArray(); .ToArray();
} }
private async Task<HashSet<string>> LoadFeaturedLists()
{
var data = await _client.GetFromJsonAsync<string[]>(_limiter,
new HttpRequestMessage(HttpMethod.Get,
"https://raw.githubusercontent.com/wabbajack-tools/mod-lists/master/featured_lists.json"), _dtos.Options);
return data!.ToHashSet(StringComparer.CurrentCultureIgnoreCase);
}
public async Task<Dictionary<string, Uri>> LoadRepositories() public async Task<Dictionary<string, Uri>> LoadRepositories()
{ {
var repositories = await _client.GetFromJsonAsync<Dictionary<string, Uri>>(_limiter, var repositories = await _client.GetFromJsonAsync<Dictionary<string, Uri>>(_limiter,