Skip to content

Commit 7e95cab

Browse files
committed
Merge remote-tracking branch 'upstream/dev' into JsonRPCUnitTest
2 parents dd8cbbb + 55e985f commit 7e95cab

File tree

10 files changed

+56
-23
lines changed

10 files changed

+56
-23
lines changed

Flow.Launcher.Core/Plugin/JsonPRCModel.cs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,8 @@ public class JsonRPCErrorModel
3030
public string Data { get; set; }
3131
}
3232

33-
public class JsonRPCModelBase
34-
{
35-
public int Id { get; set; }
36-
}
3733

38-
public class JsonRPCResponseModel : JsonRPCModelBase
34+
public class JsonRPCResponseModel
3935
{
4036
public string Result { get; set; }
4137

@@ -49,18 +45,20 @@ public class JsonRPCQueryResponseModel : JsonRPCResponseModel
4945

5046
public string DebugMessage { get; set; }
5147
}
52-
53-
public class JsonRPCRequestModel : JsonRPCModelBase
48+
49+
public class JsonRPCRequestModel
5450
{
55-
[JsonPropertyName("method")]
5651
public string Method { get; set; }
5752

58-
[JsonPropertyName("parameters")]
5953
public object[] Parameters { get; set; }
6054

55+
private static readonly JsonSerializerOptions options = new()
56+
{
57+
PropertyNamingPolicy = JsonNamingPolicy.CamelCase
58+
};
6159
public override string ToString()
6260
{
63-
return JsonSerializer.Serialize(this);
61+
return JsonSerializer.Serialize(this, options);
6462
}
6563
}
6664

@@ -77,7 +75,6 @@ public class JsonRPCServerRequestModel : JsonRPCRequestModel
7775
/// </summary>
7876
public class JsonRPCClientRequestModel : JsonRPCRequestModel
7977
{
80-
[JsonPropertyName("dontHideAfterAction")]
8178
public bool DontHideAfterAction { get; set; }
8279
}
8380

Flow.Launcher.Core/Plugin/JsonRPCPlugin.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,10 @@ public List<Result> LoadContextMenus(Result selectedResult)
4747
}
4848
}
4949

50-
private static readonly JsonSerializerOptions _options = new()
50+
private static readonly JsonSerializerOptions options = new()
5151
{
52+
PropertyNameCaseInsensitive = true,
53+
IgnoreNullValues = true,
5254
Converters =
5355
{
5456
new JsonObjectConverter()
@@ -60,8 +62,10 @@ private async Task<List<Result>> DeserializedResultAsync(Stream output)
6062
if (output == Stream.Null) return null;
6163

6264
var queryResponseModel = await
63-
JsonSerializer.DeserializeAsync<JsonRPCQueryResponseModel>(output, _options);
65+
JsonSerializer.DeserializeAsync<JsonRPCQueryResponseModel>(output, options);
6466

67+
await output.DisposeAsync();
68+
6569
return ParseResults(queryResponseModel);
6670
}
6771

@@ -70,7 +74,7 @@ private List<Result> DeserializedResult(string output)
7074
if (string.IsNullOrEmpty(output)) return null;
7175

7276
var queryResponseModel =
73-
JsonSerializer.Deserialize<JsonRPCQueryResponseModel>(output, _options);
77+
JsonSerializer.Deserialize<JsonRPCQueryResponseModel>(output, options);
7478
return ParseResults(queryResponseModel);
7579
}
7680

@@ -110,7 +114,7 @@ private List<Result> ParseResults(JsonRPCQueryResponseModel queryResponseModel)
110114
return !result.JsonRPCAction.DontHideAfterAction;
111115
}
112116

113-
var jsonRpcRequestModel = JsonSerializer.Deserialize<JsonRPCRequestModel>(actionResponse, _options);
117+
var jsonRpcRequestModel = JsonSerializer.Deserialize<JsonRPCRequestModel>(actionResponse, options);
114118

115119
if (jsonRpcRequestModel?.Method?.StartsWith("Flow.Launcher.") ?? false)
116120
{

Flow.Launcher.Core/Plugin/PluginManager.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,22 @@ public static void Save()
5858
API.SavePluginSettings();
5959
}
6060

61+
public static async ValueTask DisposePluginsAsync()
62+
{
63+
foreach (var pluginPair in AllPlugins)
64+
{
65+
switch (pluginPair.Plugin)
66+
{
67+
case IDisposable disposable:
68+
disposable.Dispose();
69+
break;
70+
case IAsyncDisposable asyncDisposable:
71+
await asyncDisposable.DisposeAsync();
72+
break;
73+
}
74+
}
75+
}
76+
6177
public static async Task ReloadData()
6278
{
6379
await Task.WhenAll(AllPlugins.Select(plugin => plugin.Plugin switch

Flow.Launcher/MainWindow.xaml.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
using Flow.Launcher.Helper;
1212
using Flow.Launcher.Infrastructure.UserSettings;
1313
using Flow.Launcher.ViewModel;
14+
using Application = System.Windows.Application;
1415
using Screen = System.Windows.Forms.Screen;
1516
using ContextMenuStrip = System.Windows.Forms.ContextMenuStrip;
1617
using DataFormats = System.Windows.DataFormats;
@@ -46,10 +47,13 @@ public MainWindow()
4647
InitializeComponent();
4748
}
4849

49-
private void OnClosing(object sender, CancelEventArgs e)
50+
private async void OnClosing(object sender, CancelEventArgs e)
5051
{
5152
_notifyIcon.Visible = false;
5253
_viewModel.Save();
54+
e.Cancel = true;
55+
await PluginManager.DisposePluginsAsync();
56+
Application.Current.Shutdown();
5357
}
5458

5559
private void OnInitialized(object sender, EventArgs e)

Flow.Launcher/Storage/UserSelectedRecord.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ public UserSelectedRecord()
2828

2929
private static int GenerateStaticHashCode(string s, int start = HASH_INITIAL)
3030
{
31+
if (s == null)
32+
{
33+
return start;
34+
}
35+
3136
unchecked
3237
{
3338
// skip the empty space
@@ -101,4 +106,4 @@ public int GetSelectedCount(Result result)
101106
return selectedCount;
102107
}
103108
}
104-
}
109+
}

Plugins/Flow.Launcher.Plugin.PluginsManager/Languages/sk.xaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
<system:String x:Key="plugin_pluginsmanager_update_title">Aktualizácia pluginu</system:String>
2020
<system:String x:Key="plugin_pluginsmanager_update_exists">Tento plugin má dostupnú aktualizáciu, chcete ju zobraziť?</system:String>
2121
<system:String x:Key="plugin_pluginsmanager_update_alreadyexists">Tento plugin je už nainštalovaný</system:String>
22+
<system:String x:Key="plugin_pluginsmanager_update_failed_title">Stiahnutie manifestu pluginu zlyhalo</system:String>
23+
<system:String x:Key="plugin_pluginsmanager_update_failed_subtitle">Skontrolujte, či sa môžete pripojiť na github.com. Táto chyba znamená, že pravdepodobne nemôžete pluginy inštalovať alebo aktualizovať.</system:String>
2224

2325
<!--Controls-->
2426

Plugins/Flow.Launcher.Plugin.PluginsManager/plugin.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"Name": "Plugins Manager",
77
"Description": "Management of installing, uninstalling or updating Flow Launcher plugins",
88
"Author": "Jeremy Wu",
9-
"Version": "1.8.2",
9+
"Version": "1.8.3",
1010
"Language": "csharp",
1111
"Website": "https://github.com/Flow-Launcher/Flow.Launcher",
1212
"ExecuteFileName": "Flow.Launcher.Plugin.PluginsManager.dll",

Plugins/Flow.Launcher.Plugin.Program/ProgramSuffixes.xaml.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System.Windows;
1+
using System;
2+
using System.Windows;
23

34
namespace Flow.Launcher.Plugin.Program
45
{
@@ -20,18 +21,21 @@ public ProgramSuffixes(PluginInitContext context, Settings settings)
2021

2122
private void ButtonBase_OnClick(object sender, RoutedEventArgs e)
2223
{
23-
if (string.IsNullOrEmpty(tbSuffixes.Text))
24+
var suffixes = tbSuffixes.Text.Split(Settings.SuffixSeperator, StringSplitOptions.RemoveEmptyEntries);
25+
26+
if (suffixes.Length == 0)
2427
{
2528
string warning = context.API.GetTranslation("flowlauncher_plugin_program_suffixes_cannot_empty");
2629
MessageBox.Show(warning);
2730
return;
2831
}
2932

30-
_settings.ProgramSuffixes = tbSuffixes.Text.Split(Settings.SuffixSeperator);
33+
_settings.ProgramSuffixes = suffixes;
34+
3135
string msg = context.API.GetTranslation("flowlauncher_plugin_program_update_file_suffixes");
3236
MessageBox.Show(msg);
3337

3438
DialogResult = true;
3539
}
3640
}
37-
}
41+
}

Plugins/Flow.Launcher.Plugin.Program/plugin.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"Name": "Program",
55
"Description": "Search programs in Flow.Launcher",
66
"Author": "qianlifeng",
7-
"Version": "1.5.3",
7+
"Version": "1.5.4",
88
"Language": "csharp",
99
"Website": "https://github.com/Flow-Launcher/Flow.Launcher",
1010
"ExecuteFileName": "Flow.Launcher.Plugin.Program.dll",

Plugins/Flow.Launcher.Plugin.WebSearch/Languages/sk.xaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
22
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
33
xmlns:system="clr-namespace:System;assembly=mscorlib">
4+
45
<system:String x:Key="flowlauncher_plugin_websearch_open_search_in">Otvoriť vyhľadávanie v:</system:String>
56
<system:String x:Key="flowlauncher_plugin_websearch_new_window">Nové okno</system:String>
67
<system:String x:Key="flowlauncher_plugin_websearch_new_tab">Nová karta</system:String>

0 commit comments

Comments
 (0)