Skip to content

Commit

Permalink
Merge #2694 Only update mod list once at GUI startup
Browse files Browse the repository at this point in the history
  • Loading branch information
politas committed Mar 21, 2019
2 parents 9a816ea + 32f15b2 commit 3ca6b2b
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 16 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ All notable changes to this project will be documented in this file.
- [GUI] Allow replacement by conflicting modules (#2695 by: HebaruSan; reviewed: politas)
- [GUI] Sort AD above empty checkboxes (#2691 by: HebaruSan; reviewed: politas)
- [Netkan] Reinstate no releases warnings for Netkan (#2692 by: HebaruSan; reviewed: politas)
- [GUI] Only update mod list once at GUI startup (#2694 by: HebaruSan; reviewed: politas)

## v1.25.4 Kennedy

Expand Down
33 changes: 17 additions & 16 deletions GUI/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -386,19 +386,7 @@ protected override void OnLoad(EventArgs e)

ApplyToolButton.Enabled = false;

CurrentInstanceUpdated();

// We would like to refresh if we're configured to refresh on startup,
// or if we have no currently available modules.
bool repoUpdateNeeded = configuration.RefreshOnStartup
|| !RegistryManager.Instance(CurrentInstance).registry.HasAnyAvailable();
// If we're auto-updating the client then we shouldn't interfere with the progress tab
if (!autoUpdating && repoUpdateNeeded)
{
UpdateRepo();
}

Text = $"CKAN {Meta.GetVersion()} - KSP {CurrentInstance.Version()} -- {CurrentInstance.GameDir()}";
CurrentInstanceUpdated(!autoUpdating);

if (commandLineArgs.Length >= 2)
{
Expand Down Expand Up @@ -504,7 +492,11 @@ protected override void OnFormClosing(FormClosingEventArgs e)
base.OnFormClosing(e);
}

private void CurrentInstanceUpdated()
/// <summary>
/// React to switching to a new game instance
/// </summary>
/// <param name="onStartup">true if this is the initial load and should trigger auto repo updates, false otherwise</param>
private void CurrentInstanceUpdated(bool onStartup)
{
Util.Invoke(this, () =>
{
Expand All @@ -521,7 +513,16 @@ private void CurrentInstanceUpdated()
.ShowDialog();
}

UpdateModsList();
bool repoUpdateNeeded = configuration.RefreshOnStartup
|| !RegistryManager.Instance(CurrentInstance).registry.HasAnyAvailable();
if (onStartup && repoUpdateNeeded)
{
UpdateRepo();
}
else
{
UpdateModsList();
}
ChangeSet = null;
Conflicts = null;

Expand Down Expand Up @@ -980,7 +981,7 @@ private void manageKspInstancesMenuItem_Click(object sender, EventArgs e)
var old_instance = Instance.CurrentInstance;
var result = new ManageKspInstances(!actuallyVisible).ShowDialog();
if (result == DialogResult.OK && !Equals(old_instance, Instance.CurrentInstance))
Instance.CurrentInstanceUpdated();
Instance.CurrentInstanceUpdated(false);
}

private void openKspDirectoryToolStripMenuItem_Click(object sender, EventArgs e)
Expand Down
5 changes: 5 additions & 0 deletions GUI/MainRepo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@ private void PostUpdateRepo(object sender, RunWorkerCompletedEventArgs e)
case RepoUpdateResult.NoChanges:
AddStatusMessage("Repositories already up to date.");
HideWaitDialog(true);
// Load rows if grid empty, otherwise keep current
if (ModList.Rows.Count < 1)
{
UpdateModsList(true, ChangeSet);
}
break;

case RepoUpdateResult.Failed:
Expand Down

0 comments on commit 3ca6b2b

Please sign in to comment.