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

Introduce Dependency Injection for Better Development Experience #3175

Merged
merged 38 commits into from
Feb 24, 2025
Merged
Changes from 1 commit
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
20ffff6
Use api to call api functions
Jack251970 Jan 9, 2025
8b91050
Add IApp & AppExtensions for accessing the properties & functions fro…
Jack251970 Jan 9, 2025
88e8437
Use api in app extensions to call api functions
Jack251970 Jan 9, 2025
2716c40
Move MessageBoxEx to main project for better development experience
Jack251970 Jan 9, 2025
32cac76
Improve Settings management
Jack251970 Jan 12, 2025
1b76a2b
Use dependency injection for all services
Jack251970 Jan 12, 2025
a748141
Use IPublicAPI instead
Jack251970 Jan 12, 2025
3cb9d1d
Remove IApp & AppExtensions and use dependency injection instead
Jack251970 Jan 12, 2025
2a423f0
Improve code quality
Jack251970 Jan 13, 2025
ff110b3
Fix test project build issue
Jack251970 Jan 13, 2025
c3f71c2
Revert "Fix test project build issue"
Jack251970 Jan 13, 2025
3bebb69
Fix unitest build issue
Jack251970 Jan 13, 2025
8d83849
Improve dependency injection in updater & settings view model & setti…
Jack251970 Jan 13, 2025
cdc5f0e
Merge branch 'dev' into dev4
Jack251970 Jan 13, 2025
ed39937
Initialize App.API earlier & Improve code quality
Jack251970 Jan 21, 2025
8b290a6
Merge branch 'dev' into dev4
Jack251970 Jan 21, 2025
f9983b5
Move dependency injection codes to constructor
Jack251970 Jan 22, 2025
bb25774
Merge branch 'dev' into dev4
Jack251970 Jan 26, 2025
23a1e5b
Initialize public api instance in constructor so that we can use App.…
Jack251970 Jan 27, 2025
ed16d34
Improve code quality
Jack251970 Jan 27, 2025
6a2389f
Fix test project build issue
Jack251970 Jan 27, 2025
25684a9
Merge branch 'dev' into dev4
Jack251970 Feb 17, 2025
23f6342
Merge branch 'dev' into dev4
Jack251970 Feb 18, 2025
8b6dcd0
Merge branch 'dev' into dev4
Jack251970 Feb 19, 2025
cdf02d5
Resolve conflicts
Jack251970 Feb 23, 2025
c072012
Fix parameter name issue.
Jack251970 Feb 23, 2025
39d7187
Use constructor injection for updater
Jack251970 Feb 23, 2025
39d34b1
Add circular dependency comments
Jack251970 Feb 23, 2025
e022ad6
Remove instance for StringMatcher
Jack251970 Feb 23, 2025
a3964f5
Remove instance for Internationalization & Theme
Jack251970 Feb 23, 2025
d4f9099
Improve constructor injection for updater
Jack251970 Feb 23, 2025
e989b5a
Add instance obsolete message
Jack251970 Feb 23, 2025
8496cfc
Use Ioc.Default in initialize function
Jack251970 Feb 23, 2025
ad63b0e
Improve code quality for field names
Jack251970 Feb 23, 2025
f5f0986
remove some usage of Ioc.GetRequiredService when injection is possible.
taooceros Feb 23, 2025
ef68ccb
Fix unit test issue
Jack251970 Feb 23, 2025
91490c0
Remove usage of _settingsVM._settings and make _settings private
Jack251970 Feb 23, 2025
16798a0
use constructor injection for PublicAPIInstance.cs
taooceros Feb 24, 2025
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
Next Next commit
Use api to call api functions
  • Loading branch information
Jack251970 committed Jan 9, 2025
commit 20ffff6d1b8464d6aa20c7e32e12aac1e5abd6a0
2 changes: 1 addition & 1 deletion Flow.Launcher/ActionKeywords.xaml.cs
Original file line number Diff line number Diff line change
@@ -44,7 +44,7 @@ private void btnDone_OnClick(object sender, RoutedEventArgs _)
else
{
string msg = translater.GetTranslation("newActionKeywordsHasBeenAssigned");
MessageBoxEx.Show(msg);
App.API.ShowMsgBox(msg);
}
}
}
4 changes: 3 additions & 1 deletion Flow.Launcher/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -15,13 +15,15 @@
using Flow.Launcher.Infrastructure.Image;
using Flow.Launcher.Infrastructure.Logger;
using Flow.Launcher.Infrastructure.UserSettings;
using Flow.Launcher.Plugin;
using Flow.Launcher.ViewModel;
using Stopwatch = Flow.Launcher.Infrastructure.Stopwatch;

namespace Flow.Launcher
{
public partial class App : IDisposable, ISingleInstanceApp
public partial class App : IDisposable, ISingleInstanceApp, IApp
{
public IPublicAPI PublicAPI => API;
public static PublicAPIInstance API { get; private set; }
private const string Unique = "Flow.Launcher_Unique_Application_Mutex";
private static bool _disposed;
2 changes: 1 addition & 1 deletion Flow.Launcher/CustomQueryHotkeySetting.xaml.cs
Original file line number Diff line number Diff line change
@@ -63,7 +63,7 @@ public void UpdateItem(CustomPluginHotkey item)
o.ActionKeyword == item.ActionKeyword && o.Hotkey == item.Hotkey);
if (updateCustomHotkey == null)
{
MessageBoxEx.Show(InternationalizationManager.Instance.GetTranslation("invalidPluginHotkey"));
App.API.ShowMsgBox(InternationalizationManager.Instance.GetTranslation("invalidPluginHotkey"));
Close();
return;
}
4 changes: 2 additions & 2 deletions Flow.Launcher/CustomShortcutSetting.xaml.cs
Original file line number Diff line number Diff line change
@@ -43,13 +43,13 @@ private void BtnAdd_OnClick(object sender, RoutedEventArgs e)
{
if (String.IsNullOrEmpty(Key) || String.IsNullOrEmpty(Value))
{
MessageBoxEx.Show(InternationalizationManager.Instance.GetTranslation("emptyShortcut"));
App.API.ShowMsgBox(InternationalizationManager.Instance.GetTranslation("emptyShortcut"));
return;
}
// Check if key is modified or adding a new one
if (((update && originalKey != Key) || !update) && _hotkeyVm.DoesShortcutExist(Key))
{
MessageBoxEx.Show(InternationalizationManager.Instance.GetTranslation("duplicateShortcut"));
App.API.ShowMsgBox(InternationalizationManager.Instance.GetTranslation("duplicateShortcut"));
return;
}
DialogResult = !update || originalKey != Key || originalValue != Value;
2 changes: 1 addition & 1 deletion Flow.Launcher/Helper/HotKeyMapper.cs
Original file line number Diff line number Diff line change
@@ -46,7 +46,7 @@ internal static void SetHotkey(HotkeyModel hotkey, EventHandler<HotkeyEventArgs>
{
string errorMsg = string.Format(InternationalizationManager.Instance.GetTranslation("registerHotkeyFailed"), hotkeyStr);
string errorMsgTitle = InternationalizationManager.Instance.GetTranslation("MessageBoxTitle");
MessageBoxEx.Show(errorMsg, errorMsgTitle);
App.API.ShowMsgBox(errorMsg, errorMsgTitle);
}
}

4 changes: 2 additions & 2 deletions Flow.Launcher/PriorityChangeWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -24,7 +24,7 @@ public PriorityChangeWindow(string pluginId, PluginViewModel pluginViewModel)
this.pluginViewModel = pluginViewModel;
if (plugin == null)
{
MessageBoxEx.Show(translater.GetTranslation("cannotFindSpecifiedPlugin"));
App.API.ShowMsgBox(translater.GetTranslation("cannotFindSpecifiedPlugin"));
Close();
}
}
@@ -44,7 +44,7 @@ private void btnDone_OnClick(object sender, RoutedEventArgs e)
else
{
string msg = translater.GetTranslation("invalidPriority");
MessageBoxEx.Show(msg);
App.API.ShowMsgBox(msg);
}

}
Original file line number Diff line number Diff line change
@@ -62,7 +62,7 @@ private void OpenWelcomeWindow()
[RelayCommand]
private void AskClearLogFolderConfirmation()
{
var confirmResult = MessageBoxEx.Show(
var confirmResult = App.API.ShowMsgBox(
InternationalizationManager.Instance.GetTranslation("clearlogfolderMessage"),
InternationalizationManager.Instance.GetTranslation("clearlogfolder"),
MessageBoxButton.YesNo
Original file line number Diff line number Diff line change
@@ -42,11 +42,11 @@ private void CustomHotkeyDelete()
var item = SelectedCustomPluginHotkey;
if (item is null)
{
MessageBoxEx.Show(InternationalizationManager.Instance.GetTranslation("pleaseSelectAnItem"));
App.API.ShowMsgBox(InternationalizationManager.Instance.GetTranslation("pleaseSelectAnItem"));
return;
}

var result = MessageBoxEx.Show(
var result = App.API.ShowMsgBox(
string.Format(
InternationalizationManager.Instance.GetTranslation("deleteCustomHotkeyWarning"), item.Hotkey
),
@@ -67,7 +67,7 @@ private void CustomHotkeyEdit()
var item = SelectedCustomPluginHotkey;
if (item is null)
{
MessageBoxEx.Show(InternationalizationManager.Instance.GetTranslation("pleaseSelectAnItem"));
App.API.ShowMsgBox(InternationalizationManager.Instance.GetTranslation("pleaseSelectAnItem"));
return;
}

@@ -88,11 +88,11 @@ private void CustomShortcutDelete()
var item = SelectedCustomShortcut;
if (item is null)
{
MessageBoxEx.Show(InternationalizationManager.Instance.GetTranslation("pleaseSelectAnItem"));
App.API.ShowMsgBox(InternationalizationManager.Instance.GetTranslation("pleaseSelectAnItem"));
return;
}

var result = MessageBoxEx.Show(
var result = App.API.ShowMsgBox(
string.Format(
InternationalizationManager.Instance.GetTranslation("deleteCustomShortcutWarning"), item.Key, item.Value
),
@@ -112,7 +112,7 @@ private void CustomShortcutEdit()
var item = SelectedCustomShortcut;
if (item is null)
{
MessageBoxEx.Show(InternationalizationManager.Instance.GetTranslation("pleaseSelectAnItem"));
App.API.ShowMsgBox(InternationalizationManager.Instance.GetTranslation("pleaseSelectAnItem"));
return;
}

Original file line number Diff line number Diff line change
@@ -22,7 +22,7 @@ public SettingsPaneProxyViewModel(Settings settings, Updater updater)
private void OnTestProxyClicked()
{
var message = TestProxy();
MessageBoxEx.Show(InternationalizationManager.Instance.GetTranslation(message));
App.API.ShowMsgBox(InternationalizationManager.Instance.GetTranslation(message));
}

private string TestProxy()
Original file line number Diff line number Diff line change
@@ -49,7 +49,7 @@ public bool DropShadowEffect
{
if (ThemeManager.Instance.BlurEnabled && value)
{
MessageBoxEx.Show(InternationalizationManager.Instance.GetTranslation("shadowEffectNotAllowed"));
App.API.ShowMsgBox(InternationalizationManager.Instance.GetTranslation("shadowEffectNotAllowed"));
return;
}