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

Dependency Injection Code Quality #3276

Open
wants to merge 8 commits into
base: dev
Choose a base branch
from

Conversation

Jack251970
Copy link
Contributor

@Jack251970 Jack251970 commented Feb 25, 2025

Improve code quality

  • Make PluginManager.API private
  • Remove obsoleted ThemeManager.Instance
  • Remove obsoleted InternationalizationManager.Instance and use api function App.API.GetTranslation instead
  • Remove Notification.Show and use api function App.API.ShowMsg instead

This comment has been minimized.

Copy link

gitstream-cm bot commented Feb 25, 2025

Be a legend 🏆 by adding a before and after screenshot of the changes you made, especially if they are around UI/UX.

Copy link
Contributor

coderabbitai bot commented Feb 25, 2025

📝 Walkthrough

Walkthrough

This pull request centralizes the translation retrieval mechanism throughout the codebase. Calls to the deprecated and obsolete InternationalizationManager have been replaced with calls to a centralized API (either via API, App.API, or through dependency injection using Ioc). Obsolete classes such as InternationalizationManager and ThemeManager have been removed, and several components now employ lazy initialization or dependency injection for localization and theming. Minor cleanups include revised string conventions and the removal of unused timers.

Changes

File(s) Change Summary
Flow.Launcher.Core/ExternalPlugins/Environments/AbstractPluginEnvironment.cs
Flow.Launcher.Core/Resource/Theme.cs
Flow.Launcher/Core/Updater.cs
Flow.Launcher/Converters/TextConverter.cs
Flow.Launcher/CustomQueryHotkeySetting.xaml.cs
Flow.Launcher/Helper/HotKeyMapper.cs
Flow.Launcher/HotkeyControl.xaml.cs
Flow.Launcher/HotkeyControlDialog.xaml.cs
Flow.Launcher/MainWindow.xaml.cs
Flow.Launcher/PriorityChangeWindow.xaml.cs
Flow.Launcher/SettingPages/ViewModels/SettingsPaneHotkeyViewModel.cs
Flow.Launcher/SettingPages/ViewModels/SettingsPaneProxyViewModel.cs
Flow.Launcher/ViewModel/PluginViewModel.cs
Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs
Replaced calls from InternationalizationManager.Instance.GetTranslation with API.GetTranslation, App.API.GetTranslation, or Context.API.GetTranslation to centralize localization.
Flow.Launcher.Core/Plugin/PluginManager.cs Replaced the public property API with a private static field _api using lazy initialization to improve encapsulation.
Flow.Launcher.Core/Resource/InternationalizationManager.cs
Flow.Launcher.Core/Resource/ThemeManager.cs
Removed obsolete classes to enforce usage of dependency injection (Ioc.Default.GetRequiredService<…>()) for accessing services.
Flow.Launcher.Core/Resource/LocalizedDescriptionAttribute.cs
Flow.Launcher.Core/Resource/TranslationConverter.cs
Updated translation retrieval from instance-based approaches to static API calls via a new _api field.
Flow.Launcher/App.xaml.cs
Flow.Launcher/SettingPages/ViewModels/SettingsPaneAboutViewModel.cs
Flow.Launcher/SettingPages/ViewModels/SettingsPaneGeneralViewModel.cs
Flow.Launcher/SettingPages/ViewModels/SettingsPaneThemeViewModel.cs
Flow.Launcher/ViewModel/MainViewModel.cs
Transitioned to dependency injection for managing Internationalization and Theme services; updated API calls and renamed methods (e.g., UpdateApp to UpdateAppAsync).
Flow.Launcher/CustomShortcutSetting.xaml.cs Cleaned up using directives and updated string initialization from String.Empty to string.Empty while updating translation calls.
Flow.Launcher/PublicAPIInstance.cs Updated constructor to accept an Internationalization instance, switched translation retrieval to use this instance, and added cancellation token support for HTTP methods.
Flow.Launcher/Resources/Pages/WelcomePage1.xaml.cs Replaced singleton access of Internationalization with dependency injection via Ioc.Default.GetRequiredService<Internationalization>().
Flow.Launcher/SettingPages/ViewModels/DropdownDataGeneric.cs Updated translation retrieval calls to use App.API.GetTranslation in value display methods.

Sequence Diagram(s)

sequenceDiagram
    participant UI as "UI Component"
    participant API as "App.API"
    participant DI as "Ioc/DI Container"
    participant TS as "Translation Service"

    UI->>API: GetTranslation(key)
    API->>DI: Resolve Internationalization instance
    DI-->>API: Return Internationalization instance
    API->>TS: Fetch translation for key
    TS-->>API: Return translation string
    API-->>UI: Provide translated string
Loading

Possibly related PRs

Suggested labels

enhancement, bug, kind/ux

Suggested reviewers

  • taooceros

Poem

Oh, how I hopped with glee,
As code transformed so gracefully,
Translations now dance with API might,
Obsolete classes out of sight!
In fields and hooks, my heart takes flight 🐇✨
A tiny rabbit cheers this shift tonight!


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1d3f86d and 35d5bca.

📒 Files selected for processing (1)
  • Flow.Launcher.Core/Plugin/PluginManager.cs (2 hunks)
🔇 Additional comments (2)
Flow.Launcher.Core/Plugin/PluginManager.cs (2)

31-34: Improved encapsulation with lazy initialization

The changes effectively encapsulate the IPublicAPI by replacing the public static property with a private field and property using lazy initialization. This aligns with the PR objective to "Make PluginManager.API private" and improves the code quality by:

  1. Preventing direct access to the API from outside classes
  2. Using dependency injection instead of a singleton pattern
  3. Implementing lazy initialization for better resource management

208-210: Replaced singleton instance with dependency injection

Good change! This implementation replaces the use of InternationalizationManager.Instance with proper dependency injection, which:

  1. Removes the tight coupling to a singleton
  2. Makes the code more testable
  3. Follows modern dependency injection practices

This change directly supports the PR objective to "Remove InternationalizationManager.Instance and use api function".

✨ Finishing Touches
  • 📝 Generate Docstrings

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
Flow.Launcher/PriorityChangeWindow.xaml.cs (1)

56-56: Good use of pattern matching.

Changed from a traditional type check and cast to pattern matching, which is a more modern and concise C# syntax. This improves readability.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 022cad0 and 143497d.

📒 Files selected for processing (30)
  • Flow.Launcher.Core/ExternalPlugins/Environments/AbstractPluginEnvironment.cs (2 hunks)
  • Flow.Launcher.Core/Plugin/PluginManager.cs (8 hunks)
  • Flow.Launcher.Core/Resource/InternationalizationManager.cs (0 hunks)
  • Flow.Launcher.Core/Resource/LocalizedDescriptionAttribute.cs (1 hunks)
  • Flow.Launcher.Core/Resource/Theme.cs (2 hunks)
  • Flow.Launcher.Core/Resource/ThemeManager.cs (0 hunks)
  • Flow.Launcher.Core/Resource/TranslationConverter.cs (1 hunks)
  • Flow.Launcher.Core/Updater.cs (1 hunks)
  • Flow.Launcher/ActionKeywords.xaml.cs (1 hunks)
  • Flow.Launcher/App.xaml.cs (3 hunks)
  • Flow.Launcher/Converters/TextConverter.cs (1 hunks)
  • Flow.Launcher/CustomQueryHotkeySetting.xaml.cs (2 hunks)
  • Flow.Launcher/CustomShortcutSetting.xaml.cs (2 hunks)
  • Flow.Launcher/Helper/HotKeyMapper.cs (3 hunks)
  • Flow.Launcher/HotkeyControl.xaml.cs (1 hunks)
  • Flow.Launcher/HotkeyControlDialog.xaml.cs (4 hunks)
  • Flow.Launcher/MainWindow.xaml.cs (3 hunks)
  • Flow.Launcher/PriorityChangeWindow.xaml.cs (2 hunks)
  • Flow.Launcher/PublicAPIInstance.cs (2 hunks)
  • Flow.Launcher/Resources/Pages/WelcomePage1.xaml.cs (3 hunks)
  • Flow.Launcher/SettingPages/ViewModels/DropdownDataGeneric.cs (2 hunks)
  • Flow.Launcher/SettingPages/ViewModels/SettingsPaneAboutViewModel.cs (5 hunks)
  • Flow.Launcher/SettingPages/ViewModels/SettingsPaneGeneralViewModel.cs (6 hunks)
  • Flow.Launcher/SettingPages/ViewModels/SettingsPaneHotkeyViewModel.cs (4 hunks)
  • Flow.Launcher/SettingPages/ViewModels/SettingsPaneProxyViewModel.cs (1 hunks)
  • Flow.Launcher/SettingPages/ViewModels/SettingsPaneThemeViewModel.cs (12 hunks)
  • Flow.Launcher/SettingPages/Views/SettingsPanePluginStore.xaml.cs (1 hunks)
  • Flow.Launcher/ViewModel/MainViewModel.cs (6 hunks)
  • Flow.Launcher/ViewModel/PluginViewModel.cs (2 hunks)
  • Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs (3 hunks)
💤 Files with no reviewable changes (2)
  • Flow.Launcher.Core/Resource/ThemeManager.cs
  • Flow.Launcher.Core/Resource/InternationalizationManager.cs
✅ Files skipped from review due to trivial changes (1)
  • Flow.Launcher/Helper/HotKeyMapper.cs
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: gitStream.cm
🔇 Additional comments (73)
Flow.Launcher/SettingPages/Views/SettingsPanePluginStore.xaml.cs (1)

51-51: Implementation aligns with dependency injection improvement goals.

The change from PluginManager.API.OpenUrl to App.API.OpenUrl correctly implements the PR objective of making PluginManager.API private and consolidating API access through the centralized App.API interface.

Flow.Launcher/SettingPages/ViewModels/SettingsPaneProxyViewModel.cs (1)

24-24: Successfully refactored translation access.

This change correctly implements the PR objective of removing direct dependency on InternationalizationManager.Instance by using the App.API.GetTranslation method instead.

Flow.Launcher/ViewModel/PluginViewModel.cs (4)

105-106: Translation access properly refactored.

Successfully replaced InternationalizationManager.Instance.GetTranslation with App.API.GetTranslation for string localization, aligning with the dependency injection improvements.


136-136: API access consolidated through App.API.

The change from PluginManager.API.OpenDirectory to App.API.OpenDirectory properly implements the goal of making PluginManager.API private.


142-142: API access consolidated through App.API.

The change from PluginManager.API.OpenUrl to App.API.OpenUrl correctly implements the encapsulation objective.


148-149: API access properly consolidated.

Successfully refactored to use App.API for ChangeQuery and ShowMainWindow operations, improving encapsulation and dependency management.

Flow.Launcher/SettingPages/ViewModels/SettingsPaneHotkeyViewModel.cs (4)

43-43: Translation access properly refactored in CustomHotkeyDelete.

Successfully replaced InternationalizationManager.Instance.GetTranslation with App.API.GetTranslation for multiple translation strings, improving dependency management.

Also applies to: 49-50, 51-51


68-68: Translation access properly refactored in CustomHotkeyEdit.

Correctly implemented the dependency injection approach for translations by using App.API.GetTranslation.


89-89: Translation access properly refactored in CustomShortcutDelete.

Successfully replaced InternationalizationManager.Instance.GetTranslation with App.API.GetTranslation for multiple translation strings, improving dependency management.

Also applies to: 95-96, 97-97


113-113: Translation access properly refactored in CustomShortcutEdit.

Correctly implemented the dependency injection approach for translations by using App.API.GetTranslation.

Flow.Launcher/CustomQueryHotkeySetting.xaml.cs (2)

62-62: Notification interface change looks correct.

Changed from direct usage of InternationalizationManager.Instance to App.API.GetTranslation for retrieving translations, which aligns with the PR objectives to remove InternationalizationManager.Instance in favor of API functions.


70-70: Translation change is consistent.

Using App.API.GetTranslation for consistent access to translations throughout the codebase.

Flow.Launcher/Converters/TextConverter.cs (1)

25-25: Good translation layer migration.

Changed from InternationalizationManager.Instance.GetTranslation to App.API.GetTranslation for consistency across the codebase, aligning with the PR objectives for dependency injection.

Flow.Launcher.Core/Resource/Theme.cs (2)

117-117: Correctly using injected API for translations.

Changed from using the global InternationalizationManager.Instance to using the injected _api interface for translations, which is a good practice for dependency injection and makes the code more testable.


127-127: Consistent use of injected API for translations.

Similar to the previous change, using the injected _api interface for translations instead of the singleton pattern.

Flow.Launcher/PriorityChangeWindow.xaml.cs (2)

24-24: Translation access correctly updated.

Changed from using InternationalizationManager.Instance to App.API.GetTranslation for retrieving translations, which aligns with the PR objectives.


43-44: Improved translation handling.

Simplified by directly using App.API.GetTranslation instead of storing the translation in a local variable first. This reduces unnecessary variables and makes the code more direct.

Flow.Launcher.Core/Updater.cs (1)

148-148: LGTM: Translation retrieval updated to use dependency-injected API

This change correctly transitions from using the deprecated InternationalizationManager singleton to the injected _api instance for retrieving translations, which aligns with the PR's dependency injection improvements.

Flow.Launcher.Core/Resource/LocalizedDescriptionAttribute.cs (3)

2-3: Added necessary import statements

Added imports for DI container and public API interface.


9-9: Updated translation source to use dependency injection

Properly retrieving the IPublicAPI from the DI container instead of using the deprecated InternationalizationManager singleton.


21-21: Updated translation retrieval method

Translation lookup is now correctly performed using the injected API service instead of the previous translation manager.

Flow.Launcher.Core/ExternalPlugins/Environments/AbstractPluginEnvironment.cs (1)

57-58: Translation retrieval updated to use injected API

Successfully replaced InternationalizationManager.Instance with the injected API instance for retrieving translations throughout the setup method.

Also applies to: 64-65, 87-87

Flow.Launcher.Core/Resource/TranslationConverter.cs (4)

4-5: Added necessary imports for dependency injection.

The added imports make it clear that this file now uses dependency injection through the CommunityToolkit.Mvvm package to obtain the IPublicAPI interface.


11-11: Properly injected IPublicAPI instance.

This change aligns with the PR objective to remove direct InternationalizationManager.Instance usage in favor of a more maintainable dependency injection approach.


16-18: Updated string handling and translation method.

Good changes here:

  1. Updated to lowercase string (preferred C# style)
  2. Now using the injected API for translation instead of the previous singleton

This supports the dependency injection improvements targeted by this PR.


21-21: Simplified exception handling.

The simplified ConvertBack implementation is cleaner while maintaining the same functionality.

Flow.Launcher/HotkeyControl.xaml.cs (1)

116-116: Removed dependency on InternationalizationManager singleton.

Updated to use App.API.GetTranslation instead of direct singleton access, which matches the PR objective of removing InternationalizationManager.Instance usage.

Flow.Launcher/Resources/Pages/WelcomePage1.xaml.cs (3)

6-6: Added necessary import for dependency injection.

Added the CommunityToolkit.Mvvm.DependencyInjection namespace to support the IoC container usage in this class.


21-22: Implemented proper dependency injection for Internationalization service.

Added a private readonly field that obtains the Internationalization service through dependency injection, which aligns with the PR objective to remove direct InternationalizationManager.Instance usage.


34-37: Updated translation service access.

Now using the injected _translater instance instead of the previous singleton approach for both ChangeLanguage and PromptShouldUsePinyin methods, which is consistent with the PR's dependency injection goals.

Flow.Launcher/SettingPages/ViewModels/DropdownDataGeneric.cs (2)

21-22: Updated translation retrieval method in GetValues.

Modified to use App.API.GetTranslation instead of the previous InternationalizationManager.Instance approach, aligning with the PR's goal of improving dependency management.


32-33: Updated translation retrieval method in UpdateLabels.

Consistently switched to App.API.GetTranslation for retrieving translations in the UpdateLabels method as well, maintaining the code improvements across the class.

Flow.Launcher/SettingPages/ViewModels/SettingsPaneThemeViewModel.cs (5)

10-10: Dependency Injection import added.

This change introduces the dependency injection capability, allowing for the use of Ioc.Default.GetRequiredService<Theme>().


26-26: Switched from singleton to DI-based Theme instance.

Excellent change that moves away from the singleton pattern (ThemeManager.Instance) to a properly injected service, which improves testability and reduces global state.


38-38: Theme instance accessor changed.

All references to ThemeManager.Instance have been properly replaced with the injected _theme instance, ensuring consistent use of dependency injection throughout the class.

Also applies to: 40-40, 50-50, 58-58, 62-62, 100-100, 303-303, 325-325, 347-347, 369-369, 393-393, 414-414


52-52: API message display standardized.

Changed from using Notification.Show to the standardized App.API.ShowMsgBox method, which provides a more consistent API surface.


243-244: Translation calls standardized.

Replaced direct calls to InternationalizationManager.Instance.GetTranslation with the API-based approach App.API.GetTranslation, making internationalization more consistent throughout the codebase.

Also applies to: 252-253, 261-262, 270-271

Flow.Launcher/ActionKeywords.xaml.cs (1)

43-43: Translation call standardized.

Replaced translater.GetTranslation with App.API.GetTranslation, aligning with the PR objective to centralize translation access.

Flow.Launcher/SettingPages/ViewModels/SettingsPaneAboutViewModel.cs (3)

25-25: Translation calls standardized.

All calls to InternationalizationManager.Instance.GetTranslation have been properly replaced with App.API.GetTranslation, providing a more consistent approach to internationalization.

Also applies to: 43-44, 64-66


78-78: Directory access standardized.

Changed direct directory operations to use the centralized API method App.API.OpenDirectory, improving code consistency.

Also applies to: 86-86


97-97: Method naming improved for async method.

Renamed UpdateApp to UpdateAppAsync to better follow naming conventions for asynchronous methods, making the code more maintainable.

Flow.Launcher/MainWindow.xaml.cs (2)

349-354: Translation calls standardized in menu and tooltips.

All menu item headers and tooltips now use App.API.GetTranslation instead of direct internationalization manager calls, providing a more consistent API surface.

Also applies to: 376-376, 381-381, 387-387, 393-393, 402-403


438-438: Settings save standardized.

Changed from direct settings save to using the centralized API method App.API.SaveAppAllSettings, improving code consistency.

Flow.Launcher/CustomShortcutSetting.xaml.cs (3)

10-11: String.Empty changed to string.Empty for consistency.

This change follows C# convention by using lowercase string instead of the class name String for consistency in the codebase.


41-43: Properly replaced direct translation call with API function.

The code now uses App.API.ShowMsgBox with App.API.GetTranslation instead of direct calls to InternationalizationManager, which aligns with the PR objective of improved dependency injection.


49-50: Translation and notification calls consolidated through the API.

Consistent with the other change in this file, this properly replaces direct calls to InternationalizationManager with API functions.

Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs (2)

166-166: Plugin translation call properly updated to use Context.API.

Changed from using InternationalizationManager.Instance.GetTranslation to Context.API.GetTranslation, which aligns with the PR objective while using the plugin's appropriate context object.


321-321: Updated tooltip translation to use Context.API consistently.

This change follows the same pattern as the previous translation update in this file, maintaining consistency in how translations are retrieved throughout the plugin.

Flow.Launcher.Core/Plugin/PluginManager.cs (3)

32-32: Improved API encapsulation with dependency injection.

Making the API private and using dependency injection is the core change of this PR. This implementation correctly retrieves the API instance through the IoC container rather than having it set externally, which improves encapsulation and testability.


66-66: Updated all API references to use the private field.

All references to the previously public API property have been consistently replaced with the private _api field throughout the file. This maintains the functionality while improving encapsulation.

Also applies to: 171-171, 213-216, 523-523, 558-559, 572-573, 589-590


206-208: Improved internationalization with proper DI pattern.

The code now correctly uses dependency injection to get the Internationalization service rather than accessing a singleton directly. This is a significant improvement in the architecture that aligns with modern dependency injection practices.

Flow.Launcher/HotkeyControlDialog.xaml.cs (2)

34-34: Replaced static translation with App.API call.

The static property now correctly uses the API for translation instead of accessing the InternationalizationManager directly, aligning with the PR objectives.


42-43: Consistently updated all translation calls to use App.API.

All instances of InternationalizationManager.Instance.GetTranslation have been replaced with App.API.GetTranslation, maintaining a consistent approach throughout the class.

Also applies to: 142-144, 149-151, 161-163, 177-178

Flow.Launcher/App.xaml.cs (3)

94-94: Dependency injection for internationalization: Good change.

This change replaces a direct call to InternationalizationManager.Instance with dependency injection using Ioc.Default.GetRequiredService<Internationalization>(), improving code maintainability by reducing reliance on singletons.


114-114: Dependency injection for theme management: Good change.

Similar to the internationalization change, this replaces a direct call to ThemeManager.Instance with dependency injection, making the code more modular and testable.


144-144: Consolidated message display through API: Good change.

Replaced direct calls to notification and translation systems with a consolidated API approach using API.ShowMsg and API.GetTranslation, improving consistency and maintainability.

Flow.Launcher/PublicAPIInstance.cs (4)

37-37: Added translation service field: Good change.

Adding a private field for the translation service that will be injected through the constructor.


42-42: Constructor dependency injection: Good change.

Constructor now accepts Internationalization parameter and properly stores it in the _translater field, following dependency injection best practices.

Also applies to: 45-46


158-158: Translation method implementation: Good change.

Replaced direct call to InternationalizationManager.Instance with the injected _translater service, reducing tight coupling and improving testability.


165-165: Added cancellation token support: Good enhancement.

HTTP methods now include optional CancellationToken parameters, allowing for better control over asynchronous operations and potential cancellation.

Also applies to: 167-168

Flow.Launcher/SettingPages/ViewModels/SettingsPaneGeneralViewModel.cs (5)

4-4: Added dependency injection namespace: Good change.

Added the namespace for DependencyInjection to support retrieving services from the IoC container.


51-51: Using API for notifications and translations: Good change.

Replaced direct call to Notification.Show with App.API.ShowMsg and using App.API.GetTranslation for localization, improving consistency with the rest of the codebase.


118-120: Using injected translation service: Good change.

Replaced calls to InternationalizationManager.Instance with the _translater service for language changes and Pinyin prompts, reducing dependency on singletons.


133-134: Service retrieval and language list access: Good change.

Added field initialization for the translation service using dependency injection and updated Languages property to use this service instead of the singleton.


137-138: Consistent translation approach: Good change.

All translation string retrievals now use App.API.GetTranslation instead of direct calls to the internationalization manager, ensuring consistency throughout the codebase.

Also applies to: 183-184, 195-196

Flow.Launcher/ViewModel/MainViewModel.cs (8)

251-252: Approve: Translation API usage for reload plugin message

The refactoring here properly replaces the direct call to InternationalizationManager with App.API.GetTranslation() and uses App.API.ShowMsg() for displaying notifications, which matches the PR objectives.


442-442: Approve: API usage for opening URL

Good refactoring to use App.API.OpenUrl() which centralizes external URL handling through the API.


1045-1046: Approve: Translation API usage in history query

The refactoring correctly replaces InternationalizationManager references with App.API.GetTranslation() for history-related text.


1285-1285: Approve: Translation API usage for context menu

Good replacement of direct InternationalizationManager call with App.API.GetTranslation() for the context menu title.


1291-1291: Approve: ShowMsg API usage

The refactoring properly uses App.API.ShowMsg() with App.API.GetTranslation() instead of direct calls to Notification and InternationalizationManager.


1301-1301: Approve: Translation API usage for context menu

Successfully replaces InternationalizationManager reference with App.API.GetTranslation() for the "set as top most" option.


1308-1308: Approve: ShowMsg API usage for success message

Good replacement of direct notification call with App.API.ShowMsg() that uses the translation API.


1322-1325: Approve: Translation API usage for plugin metadata

All plugin info translations are correctly migrated from InternationalizationManager to App.API.GetTranslation().

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

Copy link

gitstream-cm bot commented Feb 28, 2025

🥷 Code experts: Yusyuriv, jjw24

Jack251970, jjw24 have most 👩‍💻 activity in the files.
jjw24, Yusyuriv have most 🧠 knowledge in the files.

See details

Flow.Launcher.Core/ExternalPlugins/Environments/AbstractPluginEnvironment.cs

Activity based on git-commit:

Jack251970 jjw24
FEB
JAN 10 additions & 7 deletions
DEC
NOV 6 additions & 6 deletions
OCT
SEP

Knowledge based on git-blame:
jjw24: 54%
Yusyuriv: 4%

Flow.Launcher.Core/Plugin/PluginManager.cs

Activity based on git-commit:

Jack251970 jjw24
FEB 99 additions & 41 deletions
JAN 5 additions & 5 deletions
DEC
NOV 1 additions & 1 deletions
OCT
SEP

Knowledge based on git-blame:
jjw24: 4%
Yusyuriv: 3%

Flow.Launcher.Core/Resource/LocalizedDescriptionAttribute.cs

Activity based on git-commit:

Jack251970 jjw24
FEB
JAN
DEC
NOV
OCT
SEP

Knowledge based on git-blame:
jjw24: 96%

Flow.Launcher.Core/Resource/Theme.cs

Activity based on git-commit:

Jack251970 jjw24
FEB 64 additions & 28 deletions
JAN 7 additions & 4 deletions
DEC 2 additions & 96 deletions
NOV 2 additions & 2 deletions
OCT
SEP

Knowledge based on git-blame:
jjw24: 16%
Yusyuriv: 14%

Flow.Launcher.Core/Resource/TranslationConverter.cs

Activity based on git-commit:

Jack251970 jjw24
FEB
JAN
DEC
NOV
OCT
SEP

Knowledge based on git-blame:

Flow.Launcher.Core/Updater.cs

Activity based on git-commit:

Jack251970 jjw24
FEB 22 additions & 22 deletions
JAN 25 additions & 22 deletions
DEC
NOV 7 additions & 7 deletions
OCT
SEP

Knowledge based on git-blame:
jjw24: 12%

Flow.Launcher/ActionKeywords.xaml.cs

Activity based on git-commit:

Jack251970 jjw24
FEB
JAN 1 additions & 1 deletions
DEC
NOV 2 additions & 1 deletions
OCT
SEP

Knowledge based on git-blame:
jjw24: 25%

Flow.Launcher/App.xaml.cs

Activity based on git-commit:

Jack251970 jjw24
FEB 79 additions & 40 deletions
JAN 86 additions & 66 deletions
DEC
NOV
OCT
SEP

Knowledge based on git-blame:
jjw24: 8%
Yusyuriv: 2%

Flow.Launcher/Converters/TextConverter.cs

Activity based on git-commit:

Jack251970 jjw24
FEB
JAN
DEC
NOV
OCT
SEP

Knowledge based on git-blame:
Yusyuriv: 60%

Flow.Launcher/CustomQueryHotkeySetting.xaml.cs

Activity based on git-commit:

Jack251970 jjw24
FEB 15 additions & 15 deletions
JAN 2 additions & 5 deletions
DEC
NOV 2 additions & 2 deletions
OCT
SEP

Knowledge based on git-blame:
jjw24: 18%
Yusyuriv: 9%

Flow.Launcher/CustomShortcutSetting.xaml.cs

Activity based on git-commit:

Jack251970 jjw24
FEB 8 additions & 9 deletions
JAN 2 additions & 2 deletions
DEC
NOV 3 additions & 2 deletions
OCT
SEP

Knowledge based on git-blame:
Yusyuriv: 14%

Flow.Launcher/Helper/HotKeyMapper.cs

Activity based on git-commit:

Jack251970 jjw24
FEB 4 additions & 5 deletions 84 additions & 22 deletions
JAN 1 additions & 1 deletions
DEC
NOV 2 additions & 2 deletions
OCT
SEP

Knowledge based on git-blame:
jjw24: 39%
Yusyuriv: 36%

Flow.Launcher/HotkeyControl.xaml.cs

Activity based on git-commit:

Jack251970 jjw24
FEB 10 additions & 1 deletions
JAN
DEC
NOV
OCT
SEP

Knowledge based on git-blame:
Yusyuriv: 33%
jjw24: 6%

Flow.Launcher/HotkeyControlDialog.xaml.cs

Activity based on git-commit:

Jack251970 jjw24
FEB 27 additions & 2 deletions
JAN
DEC
NOV
OCT
SEP

Knowledge based on git-blame:
Yusyuriv: 80%
jjw24: 13%

Flow.Launcher/MainWindow.xaml.cs

Activity based on git-commit:

Jack251970 jjw24
FEB 1 additions & 1 deletions
JAN
DEC 5 additions & 10 deletions
NOV
OCT
SEP 5 additions & 0 deletions

Knowledge based on git-blame:
jjw24: 2%
Yusyuriv: 1%

Flow.Launcher/PriorityChangeWindow.xaml.cs

Activity based on git-commit:

Jack251970 jjw24
FEB
JAN 2 additions & 2 deletions
DEC
NOV 3 additions & 2 deletions
OCT
SEP

Knowledge based on git-blame:

Flow.Launcher/PublicAPIInstance.cs

Activity based on git-commit:

Jack251970 jjw24
FEB 24 additions & 3 deletions
JAN 45 additions & 47 deletions
DEC 25 additions & 32 deletions
NOV 16 additions & 0 deletions
OCT
SEP

Knowledge based on git-blame:
jjw24: 9%

Flow.Launcher/Resources/Pages/WelcomePage1.xaml.cs

Activity based on git-commit:

Jack251970 jjw24
FEB
JAN
DEC
NOV
OCT
SEP

Knowledge based on git-blame:

Flow.Launcher/SettingPages/ViewModels/DropdownDataGeneric.cs

Activity based on git-commit:

Jack251970 jjw24
FEB
JAN
DEC
NOV
OCT
SEP

Knowledge based on git-blame:
Yusyuriv: 100%

Flow.Launcher/SettingPages/ViewModels/SettingsPaneAboutViewModel.cs

Activity based on git-commit:

Jack251970 jjw24
FEB 2 additions & 3 deletions
JAN 2 additions & 2 deletions
DEC
NOV 2 additions & 3 deletions
OCT
SEP

Knowledge based on git-blame:
Yusyuriv: 91%

Flow.Launcher/SettingPages/ViewModels/SettingsPaneGeneralViewModel.cs

Activity based on git-commit:

Jack251970 jjw24
FEB 17 additions & 8 deletions
JAN 33 additions & 3 deletions
DEC
NOV
OCT
SEP

Knowledge based on git-blame:
Yusyuriv: 83%

Flow.Launcher/SettingPages/ViewModels/SettingsPaneHotkeyViewModel.cs

Activity based on git-commit:

Jack251970 jjw24
FEB
JAN 8 additions & 9 deletions
DEC
NOV 12 additions & 11 deletions
OCT
SEP

Knowledge based on git-blame:
Yusyuriv: 93%

Flow.Launcher/SettingPages/ViewModels/SettingsPaneProxyViewModel.cs

Activity based on git-commit:

Jack251970 jjw24
FEB
JAN 1 additions & 1 deletions
DEC
NOV 1 additions & 2 deletions
OCT
SEP

Knowledge based on git-blame:
Yusyuriv: 98%

Flow.Launcher/SettingPages/ViewModels/SettingsPaneThemeViewModel.cs

Activity based on git-commit:

Jack251970 jjw24
FEB 1 additions & 20 deletions
JAN 1 additions & 1 deletions
DEC
NOV 2 additions & 2 deletions
OCT
SEP

Knowledge based on git-blame:
Yusyuriv: 72%

Flow.Launcher/ViewModel/MainViewModel.cs

Activity based on git-commit:

Jack251970 jjw24
FEB 63 additions & 21 deletions
JAN 17 additions & 21 deletions
DEC 59 additions & 63 deletions
NOV 39 additions & 15 deletions
OCT
SEP

Knowledge based on git-blame:
Yusyuriv: 3%
jjw24: 2%

Flow.Launcher/ViewModel/PluginViewModel.cs

Activity based on git-commit:

Jack251970 jjw24
FEB 7 additions & 8 deletions
JAN
DEC
NOV
OCT
SEP

Knowledge based on git-blame:
Yusyuriv: 27%
jjw24: 10%

Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs

Activity based on git-commit:

Jack251970 jjw24
FEB
JAN
DEC 1 additions & 1 deletions
NOV 11 additions & 12 deletions
OCT
SEP

Knowledge based on git-blame:
jjw24: 22%
Yusyuriv: 15%

To learn more about /:\ gitStream - Visit our Docs

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
Flow.Launcher.Core/Plugin/PluginManager.cs (1)

32-34: Variable naming convention inconsistency

The field api on line 33 is using camelCase while other fields like _api (referenced throughout the file) use underscore prefix. This seems inconsistent with the codebase style.

Consider using consistent naming:

-        private static IPublicAPI api = null;
-        private static IPublicAPI API => api ??= Ioc.Default.GetRequiredService<IPublicAPI>();
+        private static IPublicAPI _api = null;
+        private static IPublicAPI API => _api ??= Ioc.Default.GetRequiredService<IPublicAPI>();
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 84954be and 1d3f86d.

📒 Files selected for processing (1)
  • Flow.Launcher.Core/Plugin/PluginManager.cs (8 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: gitStream.cm
🔇 Additional comments (8)
Flow.Launcher.Core/Plugin/PluginManager.cs (8)

68-68: Good refactoring: using encapsulated API access

This correctly uses the private API instance after the refactoring to encapsulate the API.


173-173: Good refactoring: using encapsulated API in plugin initialization

This correctly uses the private API instance in plugin initialization context.


208-210: Improved dependency management using IoC

The code now properly uses dependency injection to retrieve services instead of directly accessing singleton instances. This is aligned with the PR objectives to remove InternationalizationManager.Instance.


215-219: Good refactoring: using API methods for translation and notifications

The changes properly implement the PR objective to use API functions instead of direct manager access.


525-525: Good refactoring: using encapsulated API for message display

This correctly uses the encapsulated API for showing messages.


560-562: Good refactoring: using encapsulated API for reflection

The code properly uses the private API instance for reflection operations.


574-575: Good refactoring: using API methods for error messages

The changes properly implement the PR objective to use API functions instead of direct notification access.


591-592: Good refactoring: using API methods for error messages

The changes properly implement the PR objective to use API functions instead of direct notification access.

Copy link

github-actions bot commented Mar 1, 2025

@check-spelling-bot Report

🔴 Please review

See the 📂 files view, the 📜action log, or 📝 job summary for details.

❌ Errors Count
❌ forbidden-pattern 26
⚠️ ignored-expect-variant 1
⚠️ non-alpha-in-dictionary 19

See ❌ Event descriptions for more information.

Forbidden patterns 🙅 (1)

In order to address this, you could change the content to not match the forbidden patterns (comments before forbidden patterns may help explain why they're forbidden), add patterns for acceptable instances, or adjust the forbidden patterns themselves.

These forbidden patterns matched content:

s.b. workaround(s)

\bwork[- ]arounds?\b
If the flagged items are 🤯 false positives

If items relate to a ...

  • binary file (or some other file you wouldn't want to check at all).

    Please add a file path to the excludes.txt file matching the containing file.

    File paths are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your files.

    ^ refers to the file's path from the root of the repository, so ^README\.md$ would exclude README.md (on whichever branch you're using).

  • well-formed pattern.

    If you can write a pattern that would match it,
    try adding it to the patterns.txt file.

    Patterns are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your lines.

    Note that patterns can't match multiline strings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant