- Fixed an exception from temporarily unavailable Epic GraphQL
This commit is contained in:
pointfeev 2022-03-04 18:57:11 -05:00
parent c410cbdfd8
commit aaffd43168
3 changed files with 23 additions and 17 deletions

View file

@ -5,7 +5,7 @@
<UseWindowsForms>True</UseWindowsForms> <UseWindowsForms>True</UseWindowsForms>
<ApplicationIcon>Resources\ini.ico</ApplicationIcon> <ApplicationIcon>Resources\ini.ico</ApplicationIcon>
<IncludeAllContentForSelfExtract>true</IncludeAllContentForSelfExtract> <IncludeAllContentForSelfExtract>true</IncludeAllContentForSelfExtract>
<Version>3.0.2.0</Version> <Version>3.0.2.1</Version>
<PackageIcon>Resources\ini.ico</PackageIcon> <PackageIcon>Resources\ini.ico</PackageIcon>
<PackageIconUrl /> <PackageIconUrl />
<Description /> <Description />

View file

@ -20,13 +20,12 @@ internal static class EpicStore
{ {
}*/ }*/
internal static async Task<List<(string id, string name, string product, string icon, string developer)>> QueryEntitlements(Manifest manifest) internal static async Task<List<(string id, string name, string product, string icon, string developer)>> QueryEntitlements(string categoryNamespace)
{ {
string @namespace = manifest.CatalogNamespace;
List<(string id, string name, string product, string icon, string developer)> dlcIds = new(); List<(string id, string name, string product, string icon, string developer)> dlcIds = new();
Response response = await QueryGraphQL(@namespace); Response response = await QueryGraphQL(categoryNamespace);
if (response is null) return dlcIds; if (response is null) return dlcIds;
try { File.WriteAllText(ProgramData.AppInfoPath + @$"\{@namespace}.json", JsonConvert.SerializeObject(response, Formatting.Indented)); } catch { } try { File.WriteAllText(ProgramData.AppInfoPath + @$"\{categoryNamespace}.json", JsonConvert.SerializeObject(response, Formatting.Indented)); } catch { }
List<Element> searchStore = new(response.Data.Catalog.SearchStore.Elements); List<Element> searchStore = new(response.Data.Catalog.SearchStore.Elements);
foreach (Element element in searchStore) foreach (Element element in searchStore)
{ {
@ -88,6 +87,8 @@ internal static class EpicStore
} }
private static async Task<Response> QueryGraphQL(string categoryNamespace) private static async Task<Response> QueryGraphQL(string categoryNamespace)
{
try
{ {
string encoded = HttpUtility.UrlEncode(categoryNamespace); string encoded = HttpUtility.UrlEncode(categoryNamespace);
Request request = new(encoded); Request request = new(encoded);
@ -101,4 +102,9 @@ internal static class EpicStore
string response = await httpResponse.Content.ReadAsStringAsync(); string response = await httpResponse.Content.ReadAsStringAsync();
return JsonConvert.DeserializeObject<Response>(response); return JsonConvert.DeserializeObject<Response>(response);
} }
catch
{
return null;
}
}
} }

View file

@ -261,7 +261,7 @@ internal partial class SelectForm : CustomForm
if (Program.Canceled) return; if (Program.Canceled) return;
ConcurrentDictionary<string, (string name, string product, string icon, string developer)> entitlements = new(); ConcurrentDictionary<string, (string name, string product, string icon, string developer)> entitlements = new();
List<Task> dlcTasks = new(); List<Task> dlcTasks = new();
List<(string id, string name, string product, string icon, string developer)> entitlementIds = await EpicStore.QueryEntitlements(manifest); List<(string id, string name, string product, string icon, string developer)> entitlementIds = await EpicStore.QueryEntitlements(@namespace);
if (entitlementIds.Any()) if (entitlementIds.Any())
{ {
foreach ((string id, string name, string product, string icon, string developer) in entitlementIds) foreach ((string id, string name, string product, string icon, string developer) in entitlementIds)