From 1cafae827889ac0520cd16e06512d447e3bcf604 Mon Sep 17 00:00:00 2001 From: Garulf <535299+Garulf@users.noreply.github.com> Date: Sat, 18 Nov 2023 18:43:17 -0500 Subject: [PATCH 1/7] Allow nullable for Configuration --- Flow.Launcher.Core/Plugin/JsonRPCPluginSettings.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Flow.Launcher.Core/Plugin/JsonRPCPluginSettings.cs b/Flow.Launcher.Core/Plugin/JsonRPCPluginSettings.cs index b87623c56..1b14597a4 100644 --- a/Flow.Launcher.Core/Plugin/JsonRPCPluginSettings.cs +++ b/Flow.Launcher.Core/Plugin/JsonRPCPluginSettings.cs @@ -10,7 +10,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(); From 93100c0330b19d4861d6bb466f7468b8405866b6 Mon Sep 17 00:00:00 2001 From: Garulf <535299+Garulf@users.noreply.github.com> Date: Sat, 18 Nov 2023 18:43:42 -0500 Subject: [PATCH 2/7] Remove missing template file short circuit logic --- Flow.Launcher.Core/Plugin/JsonRPCPluginBase.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/Flow.Launcher.Core/Plugin/JsonRPCPluginBase.cs b/Flow.Launcher.Core/Plugin/JsonRPCPluginBase.cs index 330120c12..197932f04 100644 --- a/Flow.Launcher.Core/Plugin/JsonRPCPluginBase.cs +++ b/Flow.Launcher.Core/Plugin/JsonRPCPluginBase.cs @@ -126,8 +126,6 @@ namespace Flow.Launcher.Core.Plugin private async Task InitSettingAsync() { - if (!File.Exists(SettingConfigurationPath)) - return; var deserializer = new DeserializerBuilder().WithNamingConvention(CamelCaseNamingConvention.Instance) .Build(); From b67e815022416cc30b8aae926ef9216a08eecfa7 Mon Sep 17 00:00:00 2001 From: Garulf <535299+Garulf@users.noreply.github.com> Date: Sat, 18 Nov 2023 18:44:01 -0500 Subject: [PATCH 3/7] Load template file only if exists --- Flow.Launcher.Core/Plugin/JsonRPCPluginBase.cs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/Flow.Launcher.Core/Plugin/JsonRPCPluginBase.cs b/Flow.Launcher.Core/Plugin/JsonRPCPluginBase.cs index 197932f04..c6b56c81d 100644 --- a/Flow.Launcher.Core/Plugin/JsonRPCPluginBase.cs +++ b/Flow.Launcher.Core/Plugin/JsonRPCPluginBase.cs @@ -126,12 +126,15 @@ namespace Flow.Launcher.Core.Plugin private async Task InitSettingAsync() { + 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 { From 388688e89c26d74490ac377e17f41a2b7765241e Mon Sep 17 00:00:00 2001 From: Garulf <535299+Garulf@users.noreply.github.com> Date: Sat, 18 Nov 2023 18:44:27 -0500 Subject: [PATCH 4/7] Short circuit template UI process if doesn't exist --- Flow.Launcher.Core/Plugin/JsonRPCPluginSettings.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Flow.Launcher.Core/Plugin/JsonRPCPluginSettings.cs b/Flow.Launcher.Core/Plugin/JsonRPCPluginSettings.cs index 1b14597a4..e26f5e7a7 100644 --- a/Flow.Launcher.Core/Plugin/JsonRPCPluginSettings.cs +++ b/Flow.Launcher.Core/Plugin/JsonRPCPluginSettings.cs @@ -36,6 +36,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) From ba9aba2bff27a94810496be498271d244bf1538c Mon Sep 17 00:00:00 2001 From: Garulf <535299+Garulf@users.noreply.github.com> Date: Sat, 18 Nov 2023 18:45:16 -0500 Subject: [PATCH 5/7] Allow new setting keys to be instantiated --- Flow.Launcher.Core/Plugin/JsonRPCPluginSettings.cs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/Flow.Launcher.Core/Plugin/JsonRPCPluginSettings.cs b/Flow.Launcher.Core/Plugin/JsonRPCPluginSettings.cs index e26f5e7a7..842a91919 100644 --- a/Flow.Launcher.Core/Plugin/JsonRPCPluginSettings.cs +++ b/Flow.Launcher.Core/Plugin/JsonRPCPluginSettings.cs @@ -63,10 +63,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)) { From 5c90946a6ee99df8973096fdba3d8d69b7b3617b Mon Sep 17 00:00:00 2001 From: Garulf <535299+Garulf@users.noreply.github.com> Date: Sat, 18 Nov 2023 18:45:24 -0500 Subject: [PATCH 6/7] Save to file on update --- Flow.Launcher.Core/Plugin/JsonRPCPluginSettings.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Flow.Launcher.Core/Plugin/JsonRPCPluginSettings.cs b/Flow.Launcher.Core/Plugin/JsonRPCPluginSettings.cs index 842a91919..06d9f8dec 100644 --- a/Flow.Launcher.Core/Plugin/JsonRPCPluginSettings.cs +++ b/Flow.Launcher.Core/Plugin/JsonRPCPluginSettings.cs @@ -83,6 +83,7 @@ namespace Flow.Launcher.Core.Plugin break; } } + Save(); } } From a86e7bcaa9ed3e9a0b456bea6708f0e8b24e1442 Mon Sep 17 00:00:00 2001 From: Garulf <535299+Garulf@users.noreply.github.com> Date: Sat, 18 Nov 2023 23:15:39 -0500 Subject: [PATCH 7/7] Remove save function from loop --- Flow.Launcher.Core/Plugin/JsonRPCPluginSettings.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Flow.Launcher.Core/Plugin/JsonRPCPluginSettings.cs b/Flow.Launcher.Core/Plugin/JsonRPCPluginSettings.cs index 06d9f8dec..43215bdd5 100644 --- a/Flow.Launcher.Core/Plugin/JsonRPCPluginSettings.cs +++ b/Flow.Launcher.Core/Plugin/JsonRPCPluginSettings.cs @@ -83,8 +83,8 @@ namespace Flow.Launcher.Core.Plugin break; } } - Save(); } + Save(); } public async Task SaveAsync()