Skip to content

Commit 87aca2f

Browse files
committed
Merge branch 'binary_storage_api' of https://github.com/Jack251970/Flow.Launcher into binary_storage_api
2 parents 7da2884 + 0619041 commit 87aca2f

File tree

4 files changed

+38
-15
lines changed

4 files changed

+38
-15
lines changed

Flow.Launcher.Core/Plugin/JsonRPCV2Models/JsonRPCPublicAPI.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ namespace Flow.Launcher.Core.Plugin.JsonRPCV2Models
1212
{
1313
public class JsonRPCPublicAPI
1414
{
15-
private IPublicAPI _api;
15+
private readonly IPublicAPI _api;
1616

1717
public JsonRPCPublicAPI(IPublicAPI api)
1818
{
@@ -104,7 +104,6 @@ public List<PluginPair> GetAllPlugins()
104104
return _api.GetAllPlugins();
105105
}
106106

107-
108107
public MatchResult FuzzySearch(string query, string stringToCompare)
109108
{
110109
return _api.FuzzySearch(query, stringToCompare);
@@ -156,6 +155,11 @@ public void LogWarn(string className, string message, [CallerMemberName] string
156155
_api.LogWarn(className, message, methodName);
157156
}
158157

158+
public void LogError(string className, string message, [CallerMemberName] string methodName = "")
159+
{
160+
_api.LogError(className, message, methodName);
161+
}
162+
159163
public void OpenDirectory(string DirectoryPath, string FileNameOrFilePath = null)
160164
{
161165
_api.OpenDirectory(DirectoryPath, FileNameOrFilePath);

Flow.Launcher.Infrastructure/Logger/Log.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
using System.Diagnostics;
22
using System.IO;
33
using System.Runtime.CompilerServices;
4+
using System.Runtime.ExceptionServices;
5+
using Flow.Launcher.Infrastructure.UserSettings;
46
using NLog;
57
using NLog.Config;
68
using NLog.Targets;
7-
using Flow.Launcher.Infrastructure.UserSettings;
89
using NLog.Targets.Wrappers;
9-
using System.Runtime.ExceptionServices;
1010

1111
namespace Flow.Launcher.Infrastructure.Logger
1212
{

Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,11 @@ public interface IPublicAPI
228228
/// </summary>
229229
void LogWarn(string className, string message, [CallerMemberName] string methodName = "");
230230

231+
/// <summary>
232+
/// Log error message. Preferred error logging method for plugins.
233+
/// </summary>
234+
void LogError(string className, string message, [CallerMemberName] string methodName = "");
235+
231236
/// <summary>
232237
/// Log an Exception. Will throw if in debug mode so developer will be aware,
233238
/// otherwise logs the eror message. This is the primary logging method used for Flow

Flow.Launcher/PublicAPIInstance.cs

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
using System.Windows;
1313
using System.Windows.Media;
1414
using CommunityToolkit.Mvvm.DependencyInjection;
15-
using Squirrel;
1615
using Flow.Launcher.Core;
1716
using Flow.Launcher.Core.Plugin;
1817
using Flow.Launcher.Core.Resource;
@@ -31,6 +30,7 @@
3130
using Flow.Launcher.Plugin.SharedCommands;
3231
using Flow.Launcher.ViewModel;
3332
using JetBrains.Annotations;
33+
using Squirrel;
3434

3535
namespace Flow.Launcher
3636
{
@@ -90,7 +90,11 @@ public async void RestartApp()
9090

9191
public bool IsMainWindowVisible() => _mainVM.MainWindowVisibilityStatus;
9292

93-
public event VisibilityChangedEventHandler VisibilityChanged { add => _mainVM.VisibilityChanged += value; remove => _mainVM.VisibilityChanged -= value; }
93+
public event VisibilityChangedEventHandler VisibilityChanged
94+
{
95+
add => _mainVM.VisibilityChanged += value;
96+
remove => _mainVM.VisibilityChanged -= value;
97+
}
9498

9599
// Must use Ioc.Default.GetRequiredService<Updater>() to avoid circular dependency
96100
public void CheckForNewUpdate() => _ = Ioc.Default.GetRequiredService<Updater>().UpdateAppAsync(false);
@@ -177,13 +181,14 @@ public void CopyToClipboard(string stringToCopy, bool directCopy = false, bool s
177181
public MatchResult FuzzySearch(string query, string stringToCompare) =>
178182
StringMatcher.FuzzySearch(query, stringToCompare);
179183

180-
public Task<string> HttpGetStringAsync(string url, CancellationToken token = default) => Http.GetAsync(url, token);
184+
public Task<string> HttpGetStringAsync(string url, CancellationToken token = default) =>
185+
Http.GetAsync(url, token);
181186

182187
public Task<Stream> HttpGetStreamAsync(string url, CancellationToken token = default) =>
183188
Http.GetStreamAsync(url, token);
184189

185190
public Task HttpDownloadAsync([NotNull] string url, [NotNull] string filePath, Action<double> reportProgress = null,
186-
CancellationToken token = default) => Http.DownloadAsync(url, filePath, reportProgress, token);
191+
CancellationToken token = default) =>Http.DownloadAsync(url, filePath, reportProgress, token);
187192

188193
public void AddActionKeyword(string pluginId, string newActionKeyword) =>
189194
PluginManager.AddActionKeyword(pluginId, newActionKeyword);
@@ -202,8 +207,11 @@ public void LogInfo(string className, string message, [CallerMemberName] string
202207
public void LogWarn(string className, string message, [CallerMemberName] string methodName = "") =>
203208
Log.Warn(className, message, methodName);
204209

205-
public void LogException(string className, string message, Exception e,
206-
[CallerMemberName] string methodName = "") => Log.Exception(className, message, e, methodName);
210+
public void LogError(string className, string message, [CallerMemberName] string methodName = "") =>
211+
Log.Error(className, message, methodName);
212+
213+
public void LogException(string className, string message, Exception e, [CallerMemberName] string methodName = "") =>
214+
Log.Exception(className, message, e, methodName);
207215

208216
private readonly ConcurrentDictionary<Type, object> _pluginJsonStorages = new();
209217

@@ -216,7 +224,7 @@ public void RemovePluginSettings(string assemblyName)
216224
var name = value.GetType().GetField("AssemblyName")?.GetValue(value)?.ToString();
217225
if (name == assemblyName)
218226
{
219-
_pluginJsonStorages.TryRemove(key, out var pluginJsonStorage);
227+
_pluginJsonStorages.TryRemove(key, out var _);
220228
}
221229
}
222230
}
@@ -337,17 +345,23 @@ public bool IsGameModeOn()
337345

338346
private readonly List<Func<int, int, SpecialKeyState, bool>> _globalKeyboardHandlers = new();
339347

340-
public void RegisterGlobalKeyboardCallback(Func<int, int, SpecialKeyState, bool> callback) => _globalKeyboardHandlers.Add(callback);
341-
public void RemoveGlobalKeyboardCallback(Func<int, int, SpecialKeyState, bool> callback) => _globalKeyboardHandlers.Remove(callback);
348+
public void RegisterGlobalKeyboardCallback(Func<int, int, SpecialKeyState, bool> callback) =>
349+
_globalKeyboardHandlers.Add(callback);
350+
351+
public void RemoveGlobalKeyboardCallback(Func<int, int, SpecialKeyState, bool> callback) =>
352+
_globalKeyboardHandlers.Remove(callback);
342353

343354
public void ReQuery(bool reselect = true) => _mainVM.ReQuery(reselect);
344355

345356
public void BackToQueryResults() => _mainVM.BackToQueryResults();
346357

347-
public MessageBoxResult ShowMsgBox(string messageBoxText, string caption = "", MessageBoxButton button = MessageBoxButton.OK, MessageBoxImage icon = MessageBoxImage.None, MessageBoxResult defaultResult = MessageBoxResult.OK) =>
358+
public MessageBoxResult ShowMsgBox(string messageBoxText, string caption = "",
359+
MessageBoxButton button = MessageBoxButton.OK, MessageBoxImage icon = MessageBoxImage.None,
360+
MessageBoxResult defaultResult = MessageBoxResult.OK) =>
348361
MessageBoxEx.Show(messageBoxText, caption, button, icon, defaultResult);
349362

350-
public Task ShowProgressBoxAsync(string caption, Func<Action<double>, Task> reportProgressAsync, Action cancelProgress = null) => ProgressBoxEx.ShowAsync(caption, reportProgressAsync, cancelProgress);
363+
public Task ShowProgressBoxAsync(string caption, Func<Action<double>, Task> reportProgressAsync,
364+
Action cancelProgress = null) => ProgressBoxEx.ShowAsync(caption, reportProgressAsync, cancelProgress);
351365

352366
private readonly ConcurrentDictionary<(string, string, Type), object> _pluginBinaryStorages = new();
353367

0 commit comments

Comments
 (0)