Skip to content

Commit

Permalink
Simplified version check
Browse files Browse the repository at this point in the history
  • Loading branch information
joao-mambelli committed May 24, 2019
1 parent 03eb258 commit ab3d84d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 15 deletions.
18 changes: 4 additions & 14 deletions CSHUE/ViewModels/MainWindowViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Windows.Media;
using System.Globalization;
using System.IO;
Expand All @@ -16,7 +15,6 @@
using System.Windows.Controls;
using CSGSI;
using CSGSI.Nodes;
using CSHUE.Controls;
using CSHUE.Helpers;
using CSHUE.Views;
using Microsoft.Win32;
Expand Down Expand Up @@ -1211,8 +1209,7 @@ public void Navigate(Frame page, string pageName)
}
}

[SuppressMessage("ReSharper", "AssignNullToNotNullAttribute")]
public string CheckForUpdates()
public string GetLastVersion()
{
string data;

Expand All @@ -1225,6 +1222,8 @@ public string CheckForUpdates()

var receiveStream = response.GetResponseStream();

if (receiveStream == null) return "";

var readStream = response.CharacterSet == null
? new StreamReader(receiveStream)
: new StreamReader(receiveStream, Encoding.GetEncoding(response.CharacterSet));
Expand All @@ -1241,16 +1240,7 @@ public string CheckForUpdates()

var latestVersion = Regex.Match(data, "\"/joao7yt/CSHUE/releases/tag/(.*)\"").Groups[1].Value;

var latestVersionSplit = Regex.Match(data, "\"/joao7yt/CSHUE/releases/tag/(.*)\"").Groups[1].Value.Split('.');
var actualVersionSplit = Version.Split('.');

if (int.Parse(actualVersionSplit[0]) < int.Parse(latestVersionSplit[0]) ||
int.Parse(actualVersionSplit[1]) < int.Parse(latestVersionSplit[1]) ||
int.Parse(actualVersionSplit[2]) < int.Parse(latestVersionSplit[2]) ||
int.Parse(actualVersionSplit[3]) < int.Parse(latestVersionSplit[3]))
return latestVersion;

return "";
return Version != latestVersion ? latestVersion : "";
}

public void RunCsgo()
Expand Down
2 changes: 1 addition & 1 deletion CSHUE/Views/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ private void Window_SourceInitialized(object sender, EventArgs e)

private void MainWindow_OnInitialized(object sender, EventArgs e)
{
var latestVerstion = ViewModel.CheckForUpdates();
var latestVerstion = ViewModel.GetLastVersion();

if (latestVerstion != "" && Properties.Settings.Default.LatestVersionCheck != latestVerstion)
{
Expand Down

0 comments on commit ab3d84d

Please sign in to comment.