1
0
mirror of https://github.com/chylex/TweetDuck.git synced 2025-05-03 14:34:08 +02:00

Rewrite browser/plugin reload handling when importing a profile

This commit is contained in:
chylex 2017-08-29 14:26:42 +02:00
parent 9fd5e9443d
commit b515add94e
6 changed files with 18 additions and 20 deletions

View File

@ -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();

View File

@ -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();
}
}

View File

@ -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;
}
}

View File

@ -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;

View File

@ -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();

View File

@ -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(){