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

[Common] NotificationUtil helper class with FileWatcher #36720

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

davidegiacometti
Copy link
Collaborator

@davidegiacometti davidegiacometti commented Jan 6, 2025

Summary of the Pull Request

Replace the current WarnIfElevationIsRequired inline function with a proper helper class that uses FileWatcher.
The new helper allows to cache the option and uses the FileWatcher to listen for changes in the general settings JSON.
It will prevent AOT and FZ to constantly read the general settings JSON.

Note that WarnIfElevationIsRequired is also used by the Workspaces snapshot tool but only once.

PR Checklist

Detailed Description of the Pull Request / Additional comments

Validation Steps Performed

Tested manually:

  • General > Show a warning for functionality issues when running alongside elevated applications > Off
    • Verified that AOT, FZ and Workspaces snapshot tool don't show the notification
  • General > Show a warning for functionality issues when running alongside elevated applications > On
    • Verified that AOT, FZ and Workspaces snapshot tool show the notification
    • Verified that AOT and FZ don't show the notification a second time
  • Verified that AOT and FZ read the general settings JSON when the option is changed
  • Verified using Process Monitor that AOT and FZ don't constantly read the general settings JSON

NotificationUtil::NotificationUtil()
{
ReadSettings();
auto settingsfileName = PTSettingsHelper::get_powertoys_general_save_file_location();

Check failure

Code scanning / check-spelling

Unrecognized Spelling

[settingsfile](#security-tab) is not a recognized word. \(unrecognized-spelling\)
ReadSettings();
auto settingsfileName = PTSettingsHelper::get_powertoys_general_save_file_location();

m_settingsFileWatcher = std::make_unique<FileWatcher>(settingsfileName, [this]() {

Check failure

Code scanning / check-spelling

Unrecognized Spelling

[settingsfile](#security-tab) is not a recognized word. \(unrecognized-spelling\)
@davidegiacometti
Copy link
Collaborator Author

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

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

Successfully merging this pull request may close these issues.

1 participant