diff --git a/Flow.Launcher.Core/Plugin/JsonRPCPluginBase.cs b/Flow.Launcher.Core/Plugin/JsonRPCPluginBase.cs index b0075c8f0..f6e5e5879 100644 --- a/Flow.Launcher.Core/Plugin/JsonRPCPluginBase.cs +++ b/Flow.Launcher.Core/Plugin/JsonRPCPluginBase.cs @@ -126,14 +126,15 @@ namespace Flow.Launcher.Core.Plugin private async Task InitSettingAsync() { - if (!File.Exists(SettingConfigurationPath)) - return; + JsonRpcConfigurationModel configuration = null; + if (File.Exists(SettingConfigurationPath)) + { + var deserializer = new DeserializerBuilder().WithNamingConvention(CamelCaseNamingConvention.Instance).Build(); + configuration = + deserializer.Deserialize( + await File.ReadAllTextAsync(SettingConfigurationPath)); + } - var deserializer = new DeserializerBuilder().WithNamingConvention(CamelCaseNamingConvention.Instance) - .Build(); - var configuration = - deserializer.Deserialize( - await File.ReadAllTextAsync(SettingConfigurationPath)); Settings ??= new JsonRPCPluginSettings { diff --git a/Flow.Launcher.Core/Plugin/JsonRPCPluginSettings.cs b/Flow.Launcher.Core/Plugin/JsonRPCPluginSettings.cs index fd73a44cd..3ffac1343 100644 --- a/Flow.Launcher.Core/Plugin/JsonRPCPluginSettings.cs +++ b/Flow.Launcher.Core/Plugin/JsonRPCPluginSettings.cs @@ -11,7 +11,7 @@ namespace Flow.Launcher.Core.Plugin { public class JsonRPCPluginSettings { - public required JsonRpcConfigurationModel Configuration { get; init; } + public required JsonRpcConfigurationModel? Configuration { get; init; } public required string SettingPath { get; init; } public Dictionary SettingControls { get; } = new(); @@ -37,6 +37,11 @@ namespace Flow.Launcher.Core.Plugin _storage = new JsonStorage>(SettingPath); Settings = await _storage.LoadAsync(); + if (Settings != null) + { + return; + } + foreach (var (type, attributes) in Configuration.Body) { if (attributes.Name == null) @@ -59,10 +64,7 @@ namespace Flow.Launcher.Core.Plugin foreach (var (key, value) in settings) { - if (Settings.ContainsKey(key)) - { - Settings[key] = value; - } + Settings[key] = value; if (SettingControls.TryGetValue(key, out var control)) { @@ -83,6 +85,7 @@ namespace Flow.Launcher.Core.Plugin } } } + Save(); } public async Task SaveAsync() diff --git a/Flow.Launcher.Infrastructure/Flow.Launcher.Infrastructure.csproj b/Flow.Launcher.Infrastructure/Flow.Launcher.Infrastructure.csproj index 2f5259039..8124a95de 100644 --- a/Flow.Launcher.Infrastructure/Flow.Launcher.Infrastructure.csproj +++ b/Flow.Launcher.Infrastructure/Flow.Launcher.Infrastructure.csproj @@ -58,7 +58,7 @@ - + diff --git a/Flow.Launcher.Test/Flow.Launcher.Test.csproj b/Flow.Launcher.Test/Flow.Launcher.Test.csproj index c662fdeff..29414baa6 100644 --- a/Flow.Launcher.Test/Flow.Launcher.Test.csproj +++ b/Flow.Launcher.Test/Flow.Launcher.Test.csproj @@ -54,7 +54,7 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - + \ No newline at end of file diff --git a/Plugins/Flow.Launcher.Plugin.BrowserBookmark/Flow.Launcher.Plugin.BrowserBookmark.csproj b/Plugins/Flow.Launcher.Plugin.BrowserBookmark/Flow.Launcher.Plugin.BrowserBookmark.csproj index edaa3dd29..4ce8584fc 100644 --- a/Plugins/Flow.Launcher.Plugin.BrowserBookmark/Flow.Launcher.Plugin.BrowserBookmark.csproj +++ b/Plugins/Flow.Launcher.Plugin.BrowserBookmark/Flow.Launcher.Plugin.BrowserBookmark.csproj @@ -56,7 +56,7 @@ - + \ No newline at end of file