Skip to content

Commit

Permalink
Fixed updating trashed mods
Browse files Browse the repository at this point in the history
  • Loading branch information
TekkaGB committed Sep 14, 2021
1 parent f42f684 commit 132fc83
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Unverum/AutoUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public static async Task<bool> CheckForUnverumUpdate(CancellationTokenSource can
MessageBox.Show("Error whilst checking for Unverum update: No response from GameBanana API");
return false;
}
if (response.HasUpdates)
if (response.HasUpdates != null && (bool)response.HasUpdates)
{
GameBananaItemUpdate[] updates = response.Updates;
string updateTitle = updates[0].Title;
Expand Down
6 changes: 3 additions & 3 deletions Unverum/ModUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public async static void CheckForUpdates(string path, MainWindow main)
var MOD_ID = url.Segments[2];
requestUrls[urlCount] += $"itemtype[]={MOD_TYPE}&itemid[]={MOD_ID}&fields[]=Updates().bSubmissionHasUpdates()," +
$"Updates().aGetLatestUpdates(),Files().aFiles(),Preview().sStructuredDataFullsizeUrl()&";
if (++modCount > 24)
if (++modCount > 49)
{
requestUrls[urlCount] += "return_keys=1";
++urlCount;
Expand Down Expand Up @@ -156,15 +156,15 @@ private static async Task ModUpdate(GameBananaItem item, string mod, Metadata me
// If lastupdate doesn't exist, add one
if (metadata.lastupdate == null)
{
if (item.HasUpdates)
if (item.HasUpdates != null && (bool)item.HasUpdates)
metadata.lastupdate = item.Updates[0].DateAdded;
else
metadata.lastupdate = new DateTime(1970, 1, 1);
string metadataString = JsonSerializer.Serialize(metadata, new JsonSerializerOptions { WriteIndented = true });
File.WriteAllText($@"{mod}{Global.s}mod.json", metadataString);
return;
}
if (item.HasUpdates)
if (item.HasUpdates != null && (bool)item.HasUpdates)
{
var update = item.Updates[0];
// Compares dates of last update to current
Expand Down
8 changes: 4 additions & 4 deletions Unverum/Structures/GameBananaStructures.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ public class GameBananaItem
[JsonPropertyName("name")]
public string Name { get; set; }
[JsonPropertyName("views")]
public int Views { get; set; }
public int? Views { get; set; }
[JsonPropertyName("downloads")]
public int Downloads { get; set; }
public int? Downloads { get; set; }
[JsonPropertyName("likes")]
public int Likes { get; set; }
public int? Likes { get; set; }
[JsonPropertyName("Owner().name")]
public string Owner { get; set; }
[JsonPropertyName("description")]
Expand All @@ -30,7 +30,7 @@ public class GameBananaItem
[JsonPropertyName("Preview().sStructuredDataFullsizeUrl()")]
public Uri EmbedImage { get; set; }
[JsonPropertyName("Updates().bSubmissionHasUpdates()")]
public bool HasUpdates { get; set; }
public bool? HasUpdates { get; set; }

[JsonPropertyName("Updates().aGetLatestUpdates()")]
public GameBananaItemUpdate[] Updates { get; set; }
Expand Down
2 changes: 1 addition & 1 deletion Unverum/Unverum.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<UseWPF>true</UseWPF>
<ApplicationIcon>Assets\unverum.ico</ApplicationIcon>
<AssemblyName>Unverum</AssemblyName>
<AssemblyVersion>1.2.9.0</AssemblyVersion>
<AssemblyVersion>1.2.10.0</AssemblyVersion>
</PropertyGroup>

<ItemGroup>
Expand Down

0 comments on commit 132fc83

Please sign in to comment.