From a9e1cdffd51a2041953f11f6a279ab5bef437152 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 7 Dec 2023 22:15:29 +0000 Subject: [PATCH 1/2] Bump actions/stale from 8 to 9 Bumps [actions/stale](https://github.com/actions/stale) from 8 to 9. - [Release notes](https://github.com/actions/stale/releases) - [Changelog](https://github.com/actions/stale/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/stale/compare/v8...v9) --- updated-dependencies: - dependency-name: actions/stale dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/stale.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml index caac10c93..dd3fb2fca 100644 --- a/.github/workflows/stale.yml +++ b/.github/workflows/stale.yml @@ -13,7 +13,7 @@ jobs: issues: write pull-requests: write steps: - - uses: actions/stale@v8 + - uses: actions/stale@v9 with: stale-issue-message: 'This issue is stale because it has been open 45 days with no activity. Remove stale label or comment or this will be closed in 5 days.' days-before-stale: 45 From bdc9d02f93021c0aaf107638d1d4a2ddbb76650d Mon Sep 17 00:00:00 2001 From: Hongtao Zhang Date: Sun, 10 Dec 2023 02:26:43 -0600 Subject: [PATCH 2/2] update StreamJsonRPC, use System.Text.Json and apply serialization Option to the formatter; fix empty setting still trigger setting initialization --- Flow.Launcher.Core/Flow.Launcher.Core.csproj | 2 +- .../Plugin/JsonRPCPluginSettings.cs | 52 +++++++++---------- Flow.Launcher.Core/Plugin/JsonRPCPluginV2.cs | 8 ++- 3 files changed, 28 insertions(+), 34 deletions(-) diff --git a/Flow.Launcher.Core/Flow.Launcher.Core.csproj b/Flow.Launcher.Core/Flow.Launcher.Core.csproj index 312dfdd9e..5cd09d407 100644 --- a/Flow.Launcher.Core/Flow.Launcher.Core.csproj +++ b/Flow.Launcher.Core/Flow.Launcher.Core.csproj @@ -57,7 +57,7 @@ - + diff --git a/Flow.Launcher.Core/Plugin/JsonRPCPluginSettings.cs b/Flow.Launcher.Core/Plugin/JsonRPCPluginSettings.cs index 3ffac1343..3848af6a4 100644 --- a/Flow.Launcher.Core/Plugin/JsonRPCPluginSettings.cs +++ b/Flow.Launcher.Core/Plugin/JsonRPCPluginSettings.cs @@ -15,11 +15,11 @@ namespace Flow.Launcher.Core.Plugin public required string SettingPath { get; init; } public Dictionary SettingControls { get; } = new(); - + public IReadOnlyDictionary Inner => Settings; protected ConcurrentDictionary Settings { get; set; } public required IPublicAPI API { get; init; } - + private JsonStorage> _storage; // maybe move to resource? @@ -37,18 +37,18 @@ namespace Flow.Launcher.Core.Plugin _storage = new JsonStorage>(SettingPath); Settings = await _storage.LoadAsync(); - if (Settings != null) + if (Settings != null || Configuration == null) { return; } - foreach (var (type, attributes) in Configuration.Body) + foreach (var (type, attributes) in Configuration.Body) { if (attributes.Name == null) { continue; } - + if (!Settings.ContainsKey(attributes.Name)) { Settings[attributes.Name] = attributes.DefaultValue; @@ -56,7 +56,7 @@ namespace Flow.Launcher.Core.Plugin } } - + public void UpdateSettings(IReadOnlyDictionary settings) { if (settings == null || settings.Count == 0) @@ -80,34 +80,35 @@ namespace Flow.Launcher.Core.Plugin comboBox.Dispatcher.Invoke(() => comboBox.SelectedItem = value); break; case CheckBox checkBox: - checkBox.Dispatcher.Invoke(() => checkBox.IsChecked = value is bool isChecked ? isChecked : bool.Parse(value as string ?? string.Empty)); + checkBox.Dispatcher.Invoke(() => + checkBox.IsChecked = value is bool isChecked + ? isChecked + : bool.Parse(value as string ?? string.Empty)); break; } } } + Save(); } - + public async Task SaveAsync() { await _storage.SaveAsync(); } - + public void Save() { _storage.Save(); } - + public Control CreateSettingPanel() { - if (Settings == null) + if (Settings == null || Settings.Count == 0) return new(); var settingWindow = new UserControl(); - var mainPanel = new Grid - { - Margin = settingPanelMargin, VerticalAlignment = VerticalAlignment.Center - }; + var mainPanel = new Grid { Margin = settingPanelMargin, VerticalAlignment = VerticalAlignment.Center }; ColumnDefinition gridCol1 = new ColumnDefinition(); ColumnDefinition gridCol2 = new ColumnDefinition(); @@ -242,10 +243,7 @@ namespace Flow.Launcher.Core.Plugin Margin = new Thickness(10, 0, 0, 0), Content = "Browse" }; - var dockPanel = new DockPanel() - { - Margin = settingControlMargin - }; + var dockPanel = new DockPanel() { Margin = settingControlMargin }; DockPanel.SetDock(Btn, Dock.Right); dockPanel.Children.Add(Btn); @@ -352,7 +350,10 @@ namespace Flow.Launcher.Core.Plugin case "checkbox": var checkBox = new CheckBox { - IsChecked = Settings[attribute.Name] is bool isChecked ? isChecked : bool.Parse(attribute.DefaultValue), + IsChecked = + Settings[attribute.Name] is bool isChecked + ? isChecked + : bool.Parse(attribute.DefaultValue), Margin = settingCheckboxMargin, HorizontalAlignment = System.Windows.HorizontalAlignment.Right, ToolTip = attribute.Description @@ -375,14 +376,12 @@ namespace Flow.Launcher.Core.Plugin break; case "hyperlink": - var hyperlink = new Hyperlink - { - ToolTip = attribute.Description, NavigateUri = attribute.url - }; + var hyperlink = new Hyperlink { ToolTip = attribute.Description, NavigateUri = attribute.url }; var linkbtn = new System.Windows.Controls.Button { - HorizontalAlignment = System.Windows.HorizontalAlignment.Right, Margin = settingControlMargin + HorizontalAlignment = System.Windows.HorizontalAlignment.Right, + Margin = settingControlMargin }; linkbtn.Content = attribute.urlLabel; @@ -408,12 +407,9 @@ namespace Flow.Launcher.Core.Plugin mainPanel.Children.Add(panel); mainPanel.Children.Add(contentControl); rowCount++; - } return settingWindow; } - - } } diff --git a/Flow.Launcher.Core/Plugin/JsonRPCPluginV2.cs b/Flow.Launcher.Core/Plugin/JsonRPCPluginV2.cs index 60130843e..390da072b 100644 --- a/Flow.Launcher.Core/Plugin/JsonRPCPluginV2.cs +++ b/Flow.Launcher.Core/Plugin/JsonRPCPluginV2.cs @@ -91,7 +91,7 @@ namespace Flow.Launcher.Core.Plugin private void SetupJsonRPC() { - var formatter = new JsonMessageFormatter(); + var formatter = new SystemTextJsonFormatter { JsonSerializerOptions = RequestSerializeOption }; var handler = new NewLineDelimitedMessageHandler(ClientPipe, formatter); @@ -100,10 +100,8 @@ namespace Flow.Launcher.Core.Plugin RPC.AddLocalRpcMethod("UpdateResults", new Action((rawQuery, response) => { var results = ParseResults(response); - ResultsUpdated?.Invoke(this, new ResultUpdatedEventArgs { Query = new Query() - { - RawQuery = rawQuery - }, Results = results }); + ResultsUpdated?.Invoke(this, + new ResultUpdatedEventArgs { Query = new Query() { RawQuery = rawQuery }, Results = results }); })); RPC.SynchronizationContext = null; RPC.StartListening();