Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix API instance create twice issue & Make PluginManager.API private #3297

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Flow.Launcher.Core/Plugin/PluginManager.cs
Original file line number Diff line number Diff line change
@@ -29,7 +29,9 @@ public static class PluginManager
public static readonly HashSet<PluginPair> GlobalPlugins = new();
public static readonly Dictionary<string, PluginPair> NonGlobalPlugins = new();

public static IPublicAPI API { get; private set; } = Ioc.Default.GetRequiredService<IPublicAPI>();
// We should not initialize API in static constructor because it will create another API instance
private static IPublicAPI api = null;
private static IPublicAPI API => api ??= Ioc.Default.GetRequiredService<IPublicAPI>();

private static PluginsSettings Settings;
private static List<PluginMetadata> _metadatas;
2 changes: 1 addition & 1 deletion Flow.Launcher/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -438,7 +438,7 @@ private void CheckFirstLaunch()
if (_settings.FirstLaunch)
{
_settings.FirstLaunch = false;
PluginManager.API.SaveAppAllSettings();
App.API.SaveAppAllSettings();
OpenWelcomeWindow();
}
}
Original file line number Diff line number Diff line change
@@ -6,7 +6,6 @@
using System.Windows;
using CommunityToolkit.Mvvm.Input;
using Flow.Launcher.Core;
using Flow.Launcher.Core.Plugin;
using Flow.Launcher.Core.Resource;
using Flow.Launcher.Infrastructure;
using Flow.Launcher.Infrastructure.UserSettings;
@@ -77,15 +76,15 @@ private void AskClearLogFolderConfirmation()
[RelayCommand]
private void OpenSettingsFolder()
{
PluginManager.API.OpenDirectory(Path.Combine(DataLocation.DataDirectory(), Constant.Settings));
App.API.OpenDirectory(Path.Combine(DataLocation.DataDirectory(), Constant.Settings));
}

[RelayCommand]
private void OpenParentOfSettingsFolder(object parameter)
{
string settingsFolderPath = Path.Combine(DataLocation.DataDirectory(), Constant.Settings);
string parentFolderPath = Path.GetDirectoryName(settingsFolderPath);
PluginManager.API.OpenDirectory(parentFolderPath);
App.API.OpenDirectory(parentFolderPath);
}


Original file line number Diff line number Diff line change
@@ -3,7 +3,6 @@
using System.Windows.Data;
using System.Windows.Input;
using System.Windows.Navigation;
using Flow.Launcher.Core.Plugin;
using Flow.Launcher.SettingPages.ViewModels;
using Flow.Launcher.ViewModel;

@@ -49,7 +48,7 @@ private void SettingsPanePlugins_OnKeyDown(object sender, KeyEventArgs e)

private void Hyperlink_OnRequestNavigate(object sender, RequestNavigateEventArgs e)
{
PluginManager.API.OpenUrl(e.Uri.AbsoluteUri);
App.API.OpenUrl(e.Uri.AbsoluteUri);
e.Handled = true;
}

2 changes: 1 addition & 1 deletion Flow.Launcher/ViewModel/MainViewModel.cs
Original file line number Diff line number Diff line change
@@ -442,7 +442,7 @@ private void OpenSetting()
[RelayCommand]
private void SelectHelp()
{
PluginManager.API.OpenUrl("https://www.flowlauncher.com/docs/#/usage-tips");
App.API.OpenUrl("https://www.flowlauncher.com/docs/#/usage-tips");
}

[RelayCommand]
8 changes: 4 additions & 4 deletions Flow.Launcher/ViewModel/PluginViewModel.cs
Original file line number Diff line number Diff line change
@@ -134,20 +134,20 @@ private void OpenPluginDirectory()
{
var directory = PluginPair.Metadata.PluginDirectory;
if (!string.IsNullOrEmpty(directory))
PluginManager.API.OpenDirectory(directory);
App.API.OpenDirectory(directory);
}

[RelayCommand]
private void OpenSourceCodeLink()
{
PluginManager.API.OpenUrl(PluginPair.Metadata.Website);
App.API.OpenUrl(PluginPair.Metadata.Website);
}

[RelayCommand]
private void OpenDeletePluginWindow()
{
PluginManager.API.ChangeQuery($"{PluginManagerActionKeyword} uninstall {PluginPair.Metadata.Name}".Trim(), true);
PluginManager.API.ShowMainWindow();
App.API.ChangeQuery($"{PluginManagerActionKeyword} uninstall {PluginPair.Metadata.Name}".Trim(), true);
App.API.ShowMainWindow();
}

public static bool IsActionKeywordRegistered(string newActionKeyword) => PluginManager.ActionKeywordRegistered(newActionKeyword);

Unchanged files with check annotations Beta

pythonw
dotnet
winget
jjw24

Check failure on line 37 in .github/actions/spelling/expect.txt

GitHub Actions / Check Spelling

`2` matches a line_forbidden.patterns entry: `(?![A-Z]|[a-z]|'|\s|=).`. (forbidden-pattern)

Check failure on line 37 in .github/actions/spelling/expect.txt

GitHub Actions / Check Spelling

`4` matches a line_forbidden.patterns entry: `(?![A-Z]|[a-z]|'|\s|=).`. (forbidden-pattern)
wolframalpha
gmail
duckduckgo
EWX
dlgtext
CMD
appref-ms

Check failure on line 52 in .github/actions/spelling/expect.txt

GitHub Actions / Check Spelling

`-` matches a line_forbidden.patterns entry: `(?![A-Z]|[a-z]|'|\s|=).`. (forbidden-pattern)
appref
TSource
runas
popup
ptr
pluginindicator
TobiasSekan

Check failure on line 60 in .github/actions/spelling/expect.txt

GitHub Actions / Check Spelling

`TobiasS` matches a line_forbidden.patterns entry: `[A-Z](?:[A-Z]|[a-z]|')*?[a-z](?:[a-z]|')*[A-Z]`. (forbidden-pattern)
img
resx
bak
ddd
dddd
clearlogfolder
ACCENT_ENABLE_TRANSPARENTGRADIENT

Check failure on line 71 in .github/actions/spelling/expect.txt

GitHub Actions / Check Spelling

`_` matches a line_forbidden.patterns entry: `(?![A-Z]|[a-z]|'|\s|=).`. (forbidden-pattern)

Check failure on line 71 in .github/actions/spelling/expect.txt

GitHub Actions / Check Spelling

`_` matches a line_forbidden.patterns entry: `(?![A-Z]|[a-z]|'|\s|=).`. (forbidden-pattern)
ACCENT_ENABLE_BLURBEHIND

Check failure on line 72 in .github/actions/spelling/expect.txt

GitHub Actions / Check Spelling

`_` matches a line_forbidden.patterns entry: `(?![A-Z]|[a-z]|'|\s|=).`. (forbidden-pattern)

Check failure on line 72 in .github/actions/spelling/expect.txt

GitHub Actions / Check Spelling

`_` matches a line_forbidden.patterns entry: `(?![A-Z]|[a-z]|'|\s|=).`. (forbidden-pattern)
WCA_ACCENT_POLICY

Check failure on line 73 in .github/actions/spelling/expect.txt

GitHub Actions / Check Spelling

`_` matches a line_forbidden.patterns entry: `(?![A-Z]|[a-z]|'|\s|=).`. (forbidden-pattern)

Check failure on line 73 in .github/actions/spelling/expect.txt

GitHub Actions / Check Spelling

`_` matches a line_forbidden.patterns entry: `(?![A-Z]|[a-z]|'|\s|=).`. (forbidden-pattern)
HGlobal
dopusrt
firefox