Refactor save settings logic

SettingWindowViewModel.Save() only saves Flow settings
This commit is contained in:
Vic 2023-04-25 22:38:36 +08:00
parent 07c1a0b5a3
commit d9b70e69f3
4 changed files with 11 additions and 2 deletions

View file

@ -48,6 +48,9 @@ namespace Flow.Launcher.Core.Plugin
}
}
/// <summary>
/// Save json and ISavable
/// </summary>
public static void Save()
{
foreach (var plugin in AllPlugins)

View file

@ -77,7 +77,7 @@ namespace Flow.Launcher
public void SaveAppAllSettings()
{
SavePluginSettings();
PluginManager.Save();
_mainVM.Save();
_settingsVM.Save();
ImageLoader.Save();
@ -158,6 +158,9 @@ namespace Flow.Launcher
private readonly ConcurrentDictionary<Type, object> _pluginJsonStorages = new();
/// <summary>
/// Save plugin settings.
/// </summary>
public void SavePluginSettings()
{
foreach (var value in _pluginJsonStorages.Values)

View file

@ -226,6 +226,7 @@ namespace Flow.Launcher
settings.SettingWindowTop = Top;
settings.SettingWindowLeft = Left;
viewModel.Save();
API.SavePluginSettings();
}
private void OnCloseExecuted(object sender, ExecutedRoutedEventArgs e)

View file

@ -133,6 +133,9 @@ namespace Flow.Launcher.ViewModel
}
}
/// <summary>
/// Save Flow settings. Plugins settings are not included.
/// </summary>
public void Save()
{
foreach (var vm in PluginViewModels)
@ -143,7 +146,6 @@ namespace Flow.Launcher.ViewModel
Settings.PluginSettings.Plugins[id].Priority = vm.Priority;
}
PluginManager.Save();
_storage.Save();
}