Use ConcurrentDictionary for JsonRPC Settings

This commit is contained in:
Hongtao Zhang 2023-11-18 14:22:54 -06:00
parent 57541b351a
commit 3ec27edf75

View file

@ -1,4 +1,5 @@
using System.Collections.Generic;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
@ -16,10 +17,10 @@ namespace Flow.Launcher.Core.Plugin
public Dictionary<string, FrameworkElement> SettingControls { get; } = new();
public IReadOnlyDictionary<string, object> Inner => Settings;
protected Dictionary<string, object> Settings { get; set; }
protected ConcurrentDictionary<string, object> Settings { get; set; }
public required IPublicAPI API { get; init; }
private JsonStorage<Dictionary<string, object>> _storage;
private JsonStorage<ConcurrentDictionary<string, object>> _storage;
// maybe move to resource?
private static readonly Thickness settingControlMargin = new(0, 9, 18, 9);
@ -33,7 +34,7 @@ namespace Flow.Launcher.Core.Plugin
public async Task InitializeAsync()
{
_storage = new JsonStorage<Dictionary<string, object>>(SettingPath);
_storage = new JsonStorage<ConcurrentDictionary<string, object>>(SettingPath);
Settings = await _storage.LoadAsync();
foreach (var (type, attributes) in Configuration.Body)