Notify on repo list changed

This commit is contained in:
Raymond 2021-07-15 10:21:49 -04:00
parent d6fbe7a837
commit 2bb7f93b65
2 changed files with 35 additions and 5 deletions

View file

@ -64,9 +64,7 @@ namespace Dalamud.Plugin.Internal
var bannedPluginsJson = File.ReadAllText(Path.Combine(this.dalamud.StartInfo.AssetDirectory, "UIRes", "bannedplugin.json"));
this.bannedPlugins = JsonConvert.DeserializeObject<BannedPlugin[]>(bannedPluginsJson);
this.Repos.Add(PluginRepository.MainRepo);
this.Repos.AddRange(this.dalamud.Configuration.ThirdRepoList
.Select(repo => new PluginRepository(repo.Url, repo.IsEnabled)));
this.SetPluginReposFromConfig(false);
this.ApplyPatches();
}
@ -99,7 +97,7 @@ namespace Dalamud.Plugin.Internal
/// <summary>
/// Gets a list of all plugin repositories. The main repo should always be first.
/// </summary>
public List<PluginRepository> Repos { get; } = new();
public List<PluginRepository> Repos { get; private set; } = new();
/// <summary>
/// Gets a value indicating whether plugins are not still loading from boot.
@ -137,6 +135,22 @@ namespace Dalamud.Plugin.Internal
}
}
/// <summary>
/// Set the list of repositories to use. Should be called when the Settings window has been updated or at instantiation.
/// </summary>
/// <param name="notify">Whether the available plugins changed should be evented after.</param>
public void SetPluginReposFromConfig(bool notify)
{
var repos = new List<PluginRepository>() { PluginRepository.MainRepo };
repos.AddRange(this.dalamud.Configuration.ThirdRepoList
.Select(repo => new PluginRepository(repo.Url, repo.IsEnabled)));
this.Repos = repos;
if (notify)
this.NotifyAvailablePluginsChanged();
}
/// <summary>
/// Load all plugins, sorted by priority. Any plugins with no explicit definition file or a negative priority
/// are loaded asynchronously. Should only be called during Dalamud startup.