Skip to content

Commit

Permalink
[Runner]Delay update toast for Windows to refresh toast settings (#27671
Browse files Browse the repository at this point in the history
)
  • Loading branch information
yuyoyuppe authored Jul 28, 2023
1 parent 3e0aace commit 3a03ff0
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/runner/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ void open_menu_from_another_instance(std::optional<std::string> settings_window)

int runner(bool isProcessElevated, bool openSettings, std::string settingsWindow, bool openOobe, bool openScoobe)
{
Logger::info("Runner is starting. Elevated={}", isProcessElevated);
Logger::info("Runner is starting. Elevated={} openOobe={} openScoobe={}", isProcessElevated, openOobe, openScoobe);
DPIAware::EnableDPIAwarenessForThisProcess();

#if _DEBUG && _WIN64
Expand All @@ -108,7 +108,14 @@ int runner(bool isProcessElevated, bool openSettings, std::string settingsWindow
{
if (!openOobe && openScoobe)
{
notifications::show_toast(GET_RESOURCE_STRING(IDS_PT_VERSION_CHANGE_ASK_FOR_COMPUTER_RESTART).c_str(), L"PowerToys");
std::thread{
[] {
// Wait a bit, because Windows has a delay until it picks up toast notification registration in the registry
Sleep(10000);
Logger::info("Showing toast notification asking to restart PC");
notifications::show_toast(GET_RESOURCE_STRING(IDS_PT_VERSION_CHANGE_ASK_FOR_COMPUTER_RESTART).c_str(), L"PowerToys");
}
}.detach();
}

std::thread{ [] {
Expand Down Expand Up @@ -430,7 +437,9 @@ int WINAPI WinMain(HINSTANCE /*hInstance*/, HINSTANCE /*hPrevInstance*/, LPSTR l
try
{
std::wstring last_version_run = PTSettingsHelper::get_last_version_run();
openScoobe = last_version_run != get_product_version();
const auto product_version = get_product_version();
openScoobe = product_version != last_version_run;
Logger::info(L"Scoobe: product_version={} last_version_run={}", product_version, last_version_run);
}
catch (const std::exception& e)
{
Expand Down

0 comments on commit 3a03ff0

Please sign in to comment.