Skip to content

Commit

Permalink
Handling an error when trying to grab the github information
Browse files Browse the repository at this point in the history
  • Loading branch information
tstavrianos committed Apr 17, 2020
1 parent 2798cb4 commit b125cd5
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 15 deletions.
6 changes: 3 additions & 3 deletions BannerLordLauncher/BannerLordLauncher.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
<ApplicationIcon>BLLicon.ico</ApplicationIcon>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<RootNamespace>BannerLordLauncher</RootNamespace>
<AssemblyVersion>0.1.13.0</AssemblyVersion>
<FileVersion>0.1.13.0</FileVersion>
<AssemblyVersion>0.1.14.0</AssemblyVersion>
<FileVersion>0.1.14.0</FileVersion>
<PackageProjectUrl>https://www.nexusmods.com/mountandblade2bannerlord/mods/265</PackageProjectUrl>
<RepositoryUrl>https://github.com/tstavrianos/BannerLordLauncher</RepositoryUrl>
<Version>0.1.13</Version>
<Version>0.1.14</Version>
<StartupObject>BannerLordLauncher.Program</StartupObject>

</PropertyGroup>
Expand Down
29 changes: 17 additions & 12 deletions BannerLordLauncher/ViewModels/MainWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,8 @@ public int SelectedIndex
// ReSharper restore UnusedAutoPropertyAccessor.Global
// ReSharper restore MemberCanBePrivate.Global

private readonly GitHubClient _github;

public MainWindowViewModel(MainWindow window)
{
this._github = new GitHubClient(new ProductHeaderValue("BannerLordLauncher"));

this._ignoredWarning = true;
this._window = window;
this.Manager = new ModManager(this);
Expand Down Expand Up @@ -96,14 +92,23 @@ private void SafeMessage(string message)

private async void CheckForUpdates()
{
var currentVersion = typeof(MainWindowViewModel).Assembly.GetName().Version;
var result = await this._github.Repository.Release.GetAll("tstavrianos", "BannerLordLauncher").ConfigureAwait(false);
var latestRelease = result.OrderByDescending(x => x.CreatedAt).FirstOrDefault();
if (latestRelease == null) return;
var latestReleaseVersion = new Version(latestRelease.TagName);
if (latestReleaseVersion <= currentVersion) return;
var message = $"Version {latestReleaseVersion} is available to download";
this.SafeMessage(message);
try
{
var github = new GitHubClient(new ProductHeaderValue("BannerLordLauncher"));
var currentVersion = typeof(MainWindowViewModel).Assembly.GetName().Version;
var result = await github.Repository.Release.GetAll("tstavrianos", "BannerLordLauncher")
.ConfigureAwait(false);
var latestRelease = result.OrderByDescending(x => x.CreatedAt).FirstOrDefault();
if (latestRelease == null) return;
var latestReleaseVersion = new Version(latestRelease.TagName);
if (latestReleaseVersion <= currentVersion) return;
var message = $"Version {latestReleaseVersion} is available to download";
this.SafeMessage(message);
}
catch (Exception e)
{
this.Log().Error(e);
}
}

private void CheckAllCmd()
Expand Down

0 comments on commit b125cd5

Please sign in to comment.