diff --git a/Flow.Launcher.Core/Plugin/JsonRPCPluginSettings.cs b/Flow.Launcher.Core/Plugin/JsonRPCPluginSettings.cs index 003e72a5d86..435d97ab712 100644 --- a/Flow.Launcher.Core/Plugin/JsonRPCPluginSettings.cs +++ b/Flow.Launcher.Core/Plugin/JsonRPCPluginSettings.cs @@ -12,7 +12,7 @@ namespace Flow.Launcher.Core.Plugin { - public class JsonRPCPluginSettings + public class JsonRPCPluginSettings : ISavable { public required JsonRpcConfigurationModel? Configuration { get; init; } diff --git a/Flow.Launcher.Infrastructure/Storage/FlowLauncherJsonStorage.cs b/Flow.Launcher.Infrastructure/Storage/FlowLauncherJsonStorage.cs index 158e0cdf58c..857490badd2 100644 --- a/Flow.Launcher.Infrastructure/Storage/FlowLauncherJsonStorage.cs +++ b/Flow.Launcher.Infrastructure/Storage/FlowLauncherJsonStorage.cs @@ -2,11 +2,13 @@ using System.Threading.Tasks; using Flow.Launcher.Infrastructure.Logger; using Flow.Launcher.Infrastructure.UserSettings; +using Flow.Launcher.Plugin; using Flow.Launcher.Plugin.SharedCommands; namespace Flow.Launcher.Infrastructure.Storage { - public class FlowLauncherJsonStorage : JsonStorage where T : new() + // Expose ISaveable interface in derived class to make sure we are calling the new version of Save method + public class FlowLauncherJsonStorage : JsonStorage, ISavable where T : new() { private static readonly string ClassName = "FlowLauncherJsonStorage"; diff --git a/Flow.Launcher.Infrastructure/Storage/PluginBinaryStorage.cs b/Flow.Launcher.Infrastructure/Storage/PluginBinaryStorage.cs index 01da96d6259..0e0906e7328 100644 --- a/Flow.Launcher.Infrastructure/Storage/PluginBinaryStorage.cs +++ b/Flow.Launcher.Infrastructure/Storage/PluginBinaryStorage.cs @@ -1,11 +1,13 @@ using System.IO; using System.Threading.Tasks; using Flow.Launcher.Infrastructure.Logger; +using Flow.Launcher.Plugin; using Flow.Launcher.Plugin.SharedCommands; namespace Flow.Launcher.Infrastructure.Storage { - public class PluginBinaryStorage : BinaryStorage where T : new() + // Expose ISaveable interface in derived class to make sure we are calling the new version of Save method + public class PluginBinaryStorage : BinaryStorage, ISavable where T : new() { private static readonly string ClassName = "PluginBinaryStorage"; diff --git a/Flow.Launcher.Infrastructure/Storage/PluginJsonStorage.cs b/Flow.Launcher.Infrastructure/Storage/PluginJsonStorage.cs index 14715294958..d5908307129 100644 --- a/Flow.Launcher.Infrastructure/Storage/PluginJsonStorage.cs +++ b/Flow.Launcher.Infrastructure/Storage/PluginJsonStorage.cs @@ -2,11 +2,13 @@ using System.Threading.Tasks; using Flow.Launcher.Infrastructure.Logger; using Flow.Launcher.Infrastructure.UserSettings; +using Flow.Launcher.Plugin; using Flow.Launcher.Plugin.SharedCommands; namespace Flow.Launcher.Infrastructure.Storage { - public class PluginJsonStorage : JsonStorage where T : new() + // Expose ISaveable interface in derived class to make sure we are calling the new version of Save method + public class PluginJsonStorage : JsonStorage, ISavable where T : new() { // Use assembly name to check which plugin is using this storage public readonly string AssemblyName; diff --git a/Flow.Launcher/PublicAPIInstance.cs b/Flow.Launcher/PublicAPIInstance.cs index 80d5de53d84..17d0a875251 100644 --- a/Flow.Launcher/PublicAPIInstance.cs +++ b/Flow.Launcher/PublicAPIInstance.cs @@ -276,7 +276,7 @@ public void LogError(string className, string message, [CallerMemberName] string public void LogException(string className, string message, Exception e, [CallerMemberName] string methodName = "") => Log.Exception(className, message, e, methodName); - private readonly ConcurrentDictionary _pluginJsonStorages = new(); + private readonly ConcurrentDictionary _pluginJsonStorages = new(); public void RemovePluginSettings(string assemblyName) { @@ -294,10 +294,9 @@ public void RemovePluginSettings(string assemblyName) public void SavePluginSettings() { - foreach (var value in _pluginJsonStorages.Values) + foreach (var savable in _pluginJsonStorages.Values) { - var savable = value as ISavable; - savable?.Save(); + savable.Save(); } } @@ -496,7 +495,7 @@ public Task ShowProgressBoxAsync(string caption, Func, Task> repo public bool SetCurrentTheme(ThemeData theme) => Theme.ChangeTheme(theme.FileNameWithoutExtension); - private readonly ConcurrentDictionary<(string, string, Type), object> _pluginBinaryStorages = new(); + private readonly ConcurrentDictionary<(string, string, Type), ISavable> _pluginBinaryStorages = new(); public void RemovePluginCaches(string cacheDirectory) { @@ -513,10 +512,9 @@ public void RemovePluginCaches(string cacheDirectory) public void SavePluginCaches() { - foreach (var value in _pluginBinaryStorages.Values) + foreach (var savable in _pluginBinaryStorages.Values) { - var savable = value as ISavable; - savable?.Save(); + savable.Save(); } }