diff --git a/Core/FormBrowser.cs b/Core/FormBrowser.cs index 68e4f88f..5a03a5a2 100644 --- a/Core/FormBrowser.cs +++ b/Core/FormBrowser.cs @@ -470,7 +470,12 @@ public void OpenSettings(Type startTab){ memoryUsageTracker.Stop(); } - UpdateProperties(PropertyBridge.Environment.Browser); + if (form.ShouldReloadBrowser){ + plugins.Reload(); // also reloads the browser + } + else{ + UpdateProperties(PropertyBridge.Environment.Browser); + } notification.RequiresResize = true; form.Dispose(); diff --git a/Core/Other/FormSettings.cs b/Core/Other/FormSettings.cs index dd4f1c9b..b851cf27 100644 --- a/Core/Other/FormSettings.cs +++ b/Core/Other/FormSettings.cs @@ -19,6 +19,8 @@ sealed partial class FormSettings : Form{ private readonly Dictionary<Type, SettingsTab> tabs = new Dictionary<Type, SettingsTab>(4); private SettingsTab currentTab; + public bool ShouldReloadBrowser { get; private set; } + public FormSettings(FormBrowser browser, PluginManager plugins, UpdateHandler updates, Type startTab){ InitializeComponent(); @@ -54,6 +56,7 @@ private void FormSettings_FormClosing(object sender, FormClosingEventArgs e){ private void btnManageOptions_Click(object sender, EventArgs e){ using(DialogSettingsManage dialog = new DialogSettingsManage(plugins)){ if (dialog.ShowDialog() == DialogResult.OK){ + ShouldReloadBrowser = dialog.ShouldReloadUI; Close(); } } diff --git a/Core/Other/Settings/Dialogs/DialogSettingsManage.cs b/Core/Other/Settings/Dialogs/DialogSettingsManage.cs index c33bfa79..327800da 100644 --- a/Core/Other/Settings/Dialogs/DialogSettingsManage.cs +++ b/Core/Other/Settings/Dialogs/DialogSettingsManage.cs @@ -1,5 +1,6 @@ using System; using System.Windows.Forms; +using TweetDuck.Configuration; using TweetDuck.Core.Other.Settings.Export; using TweetDuck.Plugins; @@ -111,7 +112,12 @@ private void btnContinue_Click(object sender, EventArgs e){ case State.Import: if (importManager.Import(Flags)){ - if (!importManager.IsRestarting){ + Program.ReloadConfig(); + + if (importManager.IsRestarting){ + Program.Restart(Arguments.ArgImportCookies); + } + else{ ShouldReloadUI = true; } } diff --git a/Core/Other/Settings/Export/ExportManager.cs b/Core/Other/Settings/Export/ExportManager.cs index eb560ab1..fd32fdf8 100644 --- a/Core/Other/Settings/Export/ExportManager.cs +++ b/Core/Other/Settings/Export/ExportManager.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.IO; using System.Linq; -using TweetDuck.Configuration; using TweetDuck.Data; using TweetDuck.Plugins; using TweetDuck.Plugins.Enums; @@ -141,13 +140,6 @@ public bool Import(ExportFileFlags flags){ FormMessage.Information("Importing TweetDuck Profile", "Detected missing plugins when importing plugin data:\n"+string.Join("\n", missingPlugins), FormMessage.OK); } - if (IsRestarting){ - Program.Restart(Arguments.ArgImportCookies); - } - else{ - Program.ReloadConfig(); - } - return true; }catch(Exception e){ LastException = e; diff --git a/Plugins/PluginManager.cs b/Plugins/PluginManager.cs index a0c1056f..a8b825b7 100644 --- a/Plugins/PluginManager.cs +++ b/Plugins/PluginManager.cs @@ -45,14 +45,7 @@ public PluginManager(string rootPath, string configPath){ this.Bridge = new PluginBridge(this); Config.Load(configPath); - Config.InternalPluginChangedState += Config_InternalPluginChangedState; - Program.UserConfigReplaced += Program_UserConfigReplaced; - } - - private void Program_UserConfigReplaced(object sender, EventArgs e){ - Config.Load(configPath); - Reload(); } private void Config_InternalPluginChangedState(object sender, PluginChangedStateEventArgs e){ @@ -83,6 +76,8 @@ public Plugin GetPluginFromToken(int token){ } public void Reload(){ + Config.Load(configPath); + plugins.Clear(); tokens.Clear(); diff --git a/Program.cs b/Program.cs index e813bb7d..357a7d7b 100644 --- a/Program.cs +++ b/Program.cs @@ -52,8 +52,6 @@ static class Program{ public static Reporter Reporter { get; } public static CultureInfo Culture { get; } - public static event EventHandler UserConfigReplaced; - static Program(){ Culture = CultureInfo.CurrentCulture; Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; @@ -190,7 +188,6 @@ private static string GetDataStoragePath(){ public static void ReloadConfig(){ UserConfig = UserConfig.Load(UserConfigFilePath); - UserConfigReplaced?.Invoke(UserConfig, new EventArgs()); } public static void ResetConfig(){