private static async Task ShowChanges(MetroDialogService dialogService, Version version)
{
var progressDialog = await dialogService.ShowProgressDialog("Changelog", "Fetching release data from GitHub..");
progressDialog.SetIndeterminate();
var jsonClient = new WebClient();
// GitHub trips if we don't add a user agent
jsonClient.Headers.Add("user-agent",
"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)");
// Random number to get around cache issues
var rand = new Random(DateTime.Now.Millisecond);
var json = await jsonClient.DownloadStringTaskAsync(
"https://api.github.com/repos/SpoinkyNL/Artemis/releases?random=" + rand.Next());
// Get a list of releases
var releases = JsonConvert.DeserializeObject<JArray>(json);
var release = releases.FirstOrDefault(r => r["tag_name"].Value<string>() == version.ToString());
try
{
await progressDialog.CloseAsync();
}
catch (InvalidOperationException)
{
// Occurs when main window is closed before finished
}
if (release != null)
dialogService.ShowMessageBox(release["name"].Value<string>(), release["body"].Value<string>());
else
dialogService.ShowMessageBox("Couldn't fetch release",
"Sorry, Artemis was unable to fetch the release data off of GitHub.\n" +
"If you'd like, you can always find out the latest changes on the GitHub page accessible from the options menu");
}