Skip to content

Commit

Permalink
Made the autoupdater show the refresh tab on update
Browse files Browse the repository at this point in the history
also made the settingsdialog show the release notes before update
Closes #1347
  • Loading branch information
Postremus committed Jun 29, 2016
1 parent afb61f3 commit e013ff3
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 17 deletions.
62 changes: 47 additions & 15 deletions GUI/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -272,21 +272,7 @@ protected override void OnLoad(EventArgs e)
try
{
log.Info("Making autoupdate call");
AutoUpdate.Instance.FetchLatestReleaseInfo();
var latest_version = AutoUpdate.Instance.LatestVersion;
var current_version = new Version(Meta.Version());

if (AutoUpdate.Instance.IsFetched() && latest_version.IsGreaterThan(current_version))
{
log.Debug("Found higher ckan version");
var release_notes = AutoUpdate.Instance.ReleaseNotes;
var dialog = new NewUpdateDialog(latest_version.ToString(), release_notes);
if (dialog.ShowDialog() == DialogResult.OK)
{
log.Info("Start ckan update");
AutoUpdate.Instance.StartUpdateProcess(true);
}
}
UpdateCKAN();
}
catch (Exception exception)
{
Expand Down Expand Up @@ -406,6 +392,52 @@ public void CurrentInstanceUpdated()
Filter((GUIModFilter)m_Configuration.ActiveFilter);
}

public bool UpdateCKAN()
{
AutoUpdate updater = AutoUpdate.Instance;
if (!updater.IsFetched())
{
updater.FetchLatestReleaseInfo();
if (!updater.IsFetched())
return false;
}

Version currentVersion = new Version(Meta.Version());
if (updater.LatestVersion.IsGreaterThan(currentVersion))
{
log.Debug("Found higher ckan version");
var release_notes = updater.ReleaseNotes;
var dialog = new NewUpdateDialog(updater.LatestVersion.ToString(), release_notes);
if (dialog.ShowDialog() == DialogResult.OK)
{
log.Info("Start ckan update");

ResetProgress();
ShowWaitDialog(false);

ClearLog();
m_TabController.RenameTab("WaitTabPage", "Updating CKAN");
SetDescription("Upgrading CKAN to " + updater.LatestVersion);

BackgroundWorker CkanUpdateWorker = new BackgroundWorker
{
WorkerReportsProgress = true,
WorkerSupportsCancellation = true
};


CkanUpdateWorker.DoWork += delegate
{
AutoUpdate.Instance.StartUpdateProcess(true);
};

CkanUpdateWorker.RunWorkerAsync();
return true;
}
}
return false;
}

private void RefreshToolButton_Click(object sender, EventArgs e)
{
UpdateRepo();
Expand Down
11 changes: 9 additions & 2 deletions GUI/SettingsDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,6 @@ private void CheckForUpdatesButton_Click(object sender, EventArgs e)
{
AutoUpdate.Instance.FetchLatestReleaseInfo();
var latestVersion = AutoUpdate.Instance.LatestVersion;

if (latestVersion.IsGreaterThan(new Version(Meta.Version())) && AutoUpdate.Instance.IsFetched())
{
InstallUpdateButton.Enabled = true;
Expand All @@ -238,7 +237,15 @@ private void CheckForUpdatesButton_Click(object sender, EventArgs e)

private void InstallUpdateButton_Click(object sender, EventArgs e)
{
AutoUpdate.Instance.StartUpdateProcess(true);
this.Hide();
if (Main.Instance.UpdateCKAN())
{
Close();
}
else
{
this.Show();
}
}

private void CheckUpdateOnLaunchCheckbox_CheckedChanged(object sender, EventArgs e)
Expand Down

0 comments on commit e013ff3

Please sign in to comment.