updating: remove previous progress toasts

toast notifications:
- add method for removing existing toasts
- add method for updating existing toast contents/title
- refactoring
This commit is contained in:
yuyoyuppe
2020-10-20 14:00:06 +03:00
committed by Andrey Nekrasov
parent 5593f81242
commit 5e772340bc
9 changed files with 251 additions and 190 deletions

View File

@@ -300,7 +300,7 @@ int bootstrapper()
break; break;
} }
progressParams.progress = std::min(0.99f, progressParams.progress + 0.001f); progressParams.progress = std::min(0.99f, progressParams.progress + 0.001f);
notifications::update_progress_bar_toast(TOAST_TAG, progressParams); notifications::update_toast_progress_bar(TOAST_TAG, progressParams);
} }
} }.detach(); } }.detach();
} }
@@ -313,7 +313,7 @@ int bootstrapper()
std::scoped_lock lock{ progressLock }; std::scoped_lock lock{ progressLock };
progressParams.progress = value; progressParams.progress = value;
progressParams.progress_title = title; progressParams.progress_title = title;
notifications::update_progress_bar_toast(TOAST_TAG, progressParams); notifications::update_toast_progress_bar(TOAST_TAG, progressParams);
}; };
spdlog::debug("Extracting embedded MSI installer"); spdlog::debug("Extracting embedded MSI installer");

View File

@@ -11,7 +11,10 @@
#include <winrt/Windows.Data.Xml.Dom.h> #include <winrt/Windows.Data.Xml.Dom.h>
#include <winrt/Windows.Foundation.Collections.h> #include <winrt/Windows.Foundation.Collections.h>
#include <winrt/Windows.UI.Notifications.h> #include <winrt/Windows.UI.Notifications.h>
#include <winrt/Windows.UI.Notifications.Management.h>
#include <winrt/Windows.ApplicationModel.Background.h> #include <winrt/Windows.ApplicationModel.Background.h>
#include <winrt/Windows.System.h>
#include <winrt/Windows.System.UserProfile.h>
#include <wil/com.h> #include <wil/com.h>
#include <propvarutil.h> #include <propvarutil.h>
#include <propkey.h> #include <propkey.h>
@@ -39,6 +42,7 @@ namespace
constexpr std::wstring_view APPIDS_REGISTRY = LR"(Software\Classes\AppUserModelId\)"; constexpr std::wstring_view APPIDS_REGISTRY = LR"(Software\Classes\AppUserModelId\)";
std::wstring APPLICATION_ID = L"Microsoft.PowerToysWin32"; std::wstring APPLICATION_ID = L"Microsoft.PowerToysWin32";
constexpr std::wstring_view DEFAULT_TOAST_GROUP = L"PowerToysToastTag";
} }
namespace localized_strings namespace localized_strings
@@ -275,11 +279,10 @@ void notifications::show_toast_with_activations(std::wstring message,
std::wstring toast_xml; std::wstring toast_xml;
toast_xml.reserve(2048); toast_xml.reserve(2048);
toast_xml += LR"(<?xml version="1.0"?><toast><visual><binding template="ToastGeneric"><text id="1">)"; toast_xml += LR"(<?xml version="1.0"?><toast><visual><binding template="ToastGeneric">)";
toast_xml += title; toast_xml += LR"(<text id="1">{title}</text>)";
toast_xml += LR"(</text><text id="2">)"; toast_xml += LR"(<text id="2">{message}</text>)";
toast_xml += message;
toast_xml += L"</text>";
if (params.progress_bar.has_value()) if (params.progress_bar.has_value())
{ {
toast_xml += LR"(<progress title="{progressTitle}" value="{progressValue}" valueStringOverride="{progressValueString}" status="" />)"; toast_xml += LR"(<progress title="{progressTitle}" value="{progressValue}" valueStringOverride="{progressValueString}" status="" />)";
@@ -373,17 +376,20 @@ void notifications::show_toast_with_activations(std::wstring message,
xml_escape(toast_xml); xml_escape(toast_xml);
toast_xml_doc.LoadXml(toast_xml); toast_xml_doc.LoadXml(toast_xml);
ToastNotification notification{ toast_xml_doc }; ToastNotification notification{ toast_xml_doc };
notification.Group(DEFAULT_TOAST_GROUP);
winrt::Windows::Foundation::Collections::StringMap map;
map.Insert(L"message", std::move(message));
map.Insert(L"title", std::move(title));
if (params.progress_bar.has_value()) if (params.progress_bar.has_value())
{ {
float progress = std::clamp(params.progress_bar->progress, 0.0f, 1.0f); float progress = std::clamp(params.progress_bar->progress, 0.0f, 1.0f);
winrt::Windows::Foundation::Collections::StringMap map;
map.Insert(L"progressValue", std::to_wstring(progress)); map.Insert(L"progressValue", std::to_wstring(progress));
map.Insert(L"progressValueString", std::to_wstring(static_cast<int>(progress * 100)) + std::wstring(L"%")); map.Insert(L"progressValueString", std::to_wstring(static_cast<int>(progress * 100)) + std::wstring(L"%"));
map.Insert(L"progressTitle", params.progress_bar->progress_title); map.Insert(L"progressTitle", params.progress_bar->progress_title);
winrt::Windows::UI::Notifications::NotificationData data(map);
notification.Data(data);
} }
winrt::Windows::UI::Notifications::NotificationData data{ map };
notification.Data(std::move(data));
const auto notifier = winstore::running_as_packaged() ? ToastNotificationManager::ToastNotificationManager::CreateToastNotifier() : const auto notifier = winstore::running_as_packaged() ? ToastNotificationManager::ToastNotificationManager::CreateToastNotifier() :
ToastNotificationManager::ToastNotificationManager::CreateToastNotifier(APPLICATION_ID); ToastNotificationManager::ToastNotificationManager::CreateToastNotifier(APPLICATION_ID);
@@ -412,7 +418,7 @@ void notifications::show_toast_with_activations(std::wstring message,
} }
} }
void notifications::update_progress_bar_toast(std::wstring_view tag, progress_bar_params params) void notifications::update_toast_progress_bar(std::wstring_view tag, progress_bar_params params)
{ {
const auto notifier = winstore::running_as_packaged() ? const auto notifier = winstore::running_as_packaged() ?
ToastNotificationManager::ToastNotificationManager::CreateToastNotifier() : ToastNotificationManager::ToastNotificationManager::CreateToastNotifier() :
@@ -425,5 +431,41 @@ void notifications::update_progress_bar_toast(std::wstring_view tag, progress_ba
map.Insert(L"progressTitle", params.progress_title); map.Insert(L"progressTitle", params.progress_title);
winrt::Windows::UI::Notifications::NotificationData data(map); winrt::Windows::UI::Notifications::NotificationData data(map);
winrt::Windows::UI::Notifications::NotificationUpdateResult res = notifier.Update(data, tag); winrt::Windows::UI::Notifications::NotificationUpdateResult res = notifier.Update(data, tag, DEFAULT_TOAST_GROUP);
}
void notifications::update_toast_contents(std::wstring_view tag, std::wstring plaintext_message, std::wstring title)
{
const auto notifier = winstore::running_as_packaged() ?
ToastNotificationManager::ToastNotificationManager::CreateToastNotifier() :
ToastNotificationManager::ToastNotificationManager::CreateToastNotifier(APPLICATION_ID);
winrt::Windows::Foundation::Collections::StringMap map;
map.Insert(L"title", std::move(title));
map.Insert(L"message", std::move(plaintext_message));
winrt::Windows::UI::Notifications::NotificationData data(map);
winrt::Windows::UI::Notifications::NotificationUpdateResult res = notifier.Update(data, tag, DEFAULT_TOAST_GROUP);
}
void notifications::remove_toasts(std::wstring_view tag)
{
using namespace winrt::Windows::System;
try
{
User currentUser{ *User::FindAllAsync(UserType::LocalUser, UserAuthenticationStatus::LocallyAuthenticated).get().First() };
if (!currentUser)
{
return;
}
currentUser.GetPropertyAsync(KnownUserProperties::AccountName());
auto toastHistory = ToastNotificationManager::GetForUser(currentUser).History();
toastHistory.Remove(tag, DEFAULT_TOAST_GROUP, APPLICATION_ID);
}
catch (...)
{
// Couldn't get the current user or problem removing the toast => nothing we can do
}
} }

View File

@@ -9,6 +9,7 @@
namespace notifications namespace notifications
{ {
constexpr inline const wchar_t TOAST_ACTIVATED_LAUNCH_ARG[] = L"-ToastActivated"; constexpr inline const wchar_t TOAST_ACTIVATED_LAUNCH_ARG[] = L"-ToastActivated";
constexpr inline const wchar_t UPDATING_PROCESS_TOAST_TAG[] = L"PTUpdateNotifyTag";
void override_application_id(const std::wstring_view appID); void override_application_id(const std::wstring_view appID);
void register_background_toast_handler(); void register_background_toast_handler();
@@ -59,5 +60,7 @@ namespace notifications
void show_toast(std::wstring plaintext_message, std::wstring title, toast_params params = {}); void show_toast(std::wstring plaintext_message, std::wstring title, toast_params params = {});
void show_toast_with_activations(std::wstring plaintext_message, std::wstring title, std::wstring_view background_handler_id, std::vector<action_t> actions, toast_params params = {}); void show_toast_with_activations(std::wstring plaintext_message, std::wstring title, std::wstring_view background_handler_id, std::vector<action_t> actions, toast_params params = {});
void update_progress_bar_toast(std::wstring_view tag, progress_bar_params params); void update_toast_progress_bar(std::wstring_view tag, progress_bar_params params);
void update_toast_contents(std::wstring_view tag, std::wstring plaintext_message, std::wstring title);
void remove_toasts(std::wstring_view tag);
} }

View File

@@ -1,150 +1,161 @@
#include "pch.h" #include "pch.h"
#include "toast_notifications_helper.h" #include "notifications.h"
#include <common/notifications.h> #include <common/notifications.h>
#include "updating.h" #include "updating.h"
#include "VersionHelper.h" #include "VersionHelper.h"
#include "version.h" #include "version.h"
namespace namespace
{ {
const wchar_t UPDATE_NOTIFY_TOAST_TAG[] = L"PTUpdateNotifyTag"; const wchar_t TOAST_TITLE[] = L"PowerToys Update";
const wchar_t UPDATE_READY_TOAST_TAG[] = L"PTUpdateReadyTag"; }
const wchar_t TOAST_TITLE[] = L"PowerToys Update";
} namespace localized_strings
{
namespace localized_strings const wchar_t GITHUB_NEW_VERSION_AVAILABLE[] = L"An update to PowerToys is available.\n";
{ const wchar_t GITHUB_NEW_VERSION_DOWNLOAD_STARTED[] = L"PowerToys download started.\n";
const wchar_t GITHUB_NEW_VERSION_AVAILABLE[] = L"An update to PowerToys is available.\n"; const wchar_t GITHUB_NEW_VERSION_READY_TO_INSTALL[] = L"An update to PowerToys is ready to install.\n";
const wchar_t GITHUB_NEW_VERSION_DOWNLOAD_STARTED[] = L"PowerToys download started.\n"; const wchar_t GITHUB_NEW_VERSION_DOWNLOAD_INSTALL_ERROR[] = L"Error: couldn't download PowerToys installer. Visit our GitHub page to update.\n";
const wchar_t GITHUB_NEW_VERSION_READY_TO_INSTALL[] = L"An update to PowerToys is ready to install.\n"; const wchar_t GITHUB_NEW_VERSION_UPDATE_NOW[] = L"Update now";
const wchar_t GITHUB_NEW_VERSION_DOWNLOAD_INSTALL_ERROR[] = L"Error: couldn't download PowerToys installer. Visit our GitHub page to update.\n"; const wchar_t GITHUB_NEW_VERSION_UPDATE_AFTER_RESTART[] = L"At next launch";
const wchar_t GITHUB_NEW_VERSION_UPDATE_NOW[] = L"Update now";
const wchar_t GITHUB_NEW_VERSION_UPDATE_AFTER_RESTART[] = L"At next launch"; const wchar_t UNINSTALLATION_UNKNOWN_ERROR[] = L"Error: please uninstall the previous version of PowerToys manually.";
const wchar_t UNINSTALLATION_UNKNOWN_ERROR[] = L"Error: please uninstall the previous version of PowerToys manually."; const wchar_t GITHUB_NEW_VERSION_AVAILABLE_OFFER_VISIT[] = L"An update to PowerToys is available. Visit our GitHub page to update.\n";
const wchar_t GITHUB_NEW_VERSION_UNAVAILABLE[] = L"PowerToys is up to date.\n";
const wchar_t GITHUB_NEW_VERSION_AVAILABLE_OFFER_VISIT[] = L"An update to PowerToys is available. Visit our GitHub page to update.\n"; const wchar_t GITHUB_NEW_VERSION_VISIT[] = L"Visit";
const wchar_t GITHUB_NEW_VERSION_UNAVAILABLE[] = L"PowerToys is up to date.\n"; const wchar_t GITHUB_NEW_VERSION_MORE_INFO[] = L"More info...";
const wchar_t GITHUB_NEW_VERSION_VISIT[] = L"Visit"; const wchar_t GITHUB_NEW_VERSION_ABORT[] = L"Abort";
const wchar_t GITHUB_NEW_VERSION_MORE_INFO[] = L"More info..."; const wchar_t GITHUB_NEW_VERSION_SNOOZE_TITLE[] = L"Click Snooze to be reminded in:";
const wchar_t GITHUB_NEW_VERSION_ABORT[] = L"Abort"; const wchar_t GITHUB_NEW_VERSION_UPDATE_SNOOZE_1D[] = L"1 day";
const wchar_t GITHUB_NEW_VERSION_SNOOZE_TITLE[] = L"Click Snooze to be reminded in:"; const wchar_t GITHUB_NEW_VERSION_UPDATE_SNOOZE_5D[] = L"5 days";
const wchar_t GITHUB_NEW_VERSION_UPDATE_SNOOZE_1D[] = L"1 day"; const wchar_t DOWNLOAD_IN_PROGRESS[] = L"Downloading...";
const wchar_t GITHUB_NEW_VERSION_UPDATE_SNOOZE_5D[] = L"5 days"; const wchar_t DOWNLOAD_COMPLETE[] = L"Download complete";
const wchar_t DOWNLOAD_IN_PROGRESS[] = L"Downloading..."; }
const wchar_t DOWNLOAD_COMPLETE[] = L"Download complete";
namespace updating
} {
namespace notifications
namespace updating {
{ using namespace localized_strings;
namespace notifications using namespace ::notifications;
{ std::wstring current_version_to_next_version(const updating::new_version_download_info& info)
using namespace localized_strings; {
auto current_version_to_next_version = VersionHelper{ VERSION_MAJOR, VERSION_MINOR, VERSION_REVISION }.toWstring();
std::wstring current_version_to_next_version(const updating::new_version_download_info& info) current_version_to_next_version += L" -> ";
{ current_version_to_next_version += info.version_string;
auto current_version_to_next_version = VersionHelper{ VERSION_MAJOR, VERSION_MINOR, VERSION_REVISION }.toWstring(); return current_version_to_next_version;
current_version_to_next_version += L" -> "; }
current_version_to_next_version += info.version_string;
return current_version_to_next_version; void show_unavailable()
} {
remove_toasts(UPDATING_PROCESS_TOAST_TAG);
void show_unavailable()
{ toast_params toast_params{ UPDATING_PROCESS_TOAST_TAG, false };
::notifications::toast_params toast_params{ UPDATE_NOTIFY_TOAST_TAG, false }; std::wstring contents = GITHUB_NEW_VERSION_UNAVAILABLE;
std::wstring contents = GITHUB_NEW_VERSION_UNAVAILABLE; show_toast(std::move(contents), TOAST_TITLE, std::move(toast_params));
::notifications::show_toast(std::move(contents), TOAST_TITLE, std::move(toast_params)); }
}
void show_available(const updating::new_version_download_info& info)
void show_available(const updating::new_version_download_info& info) {
{ remove_toasts(UPDATING_PROCESS_TOAST_TAG);
::notifications::toast_params toast_params{ UPDATE_NOTIFY_TOAST_TAG, false };
std::wstring contents = GITHUB_NEW_VERSION_AVAILABLE; toast_params toast_params{ UPDATING_PROCESS_TOAST_TAG, false };
contents += current_version_to_next_version(info); std::wstring contents = GITHUB_NEW_VERSION_AVAILABLE;
contents += current_version_to_next_version(info);
::notifications::show_toast_with_activations(std::move(contents),
TOAST_TITLE, show_toast_with_activations(std::move(contents),
{}, TOAST_TITLE,
{ ::notifications::link_button{ GITHUB_NEW_VERSION_UPDATE_NOW, L"powertoys://download_and_install_update/" }, ::notifications::link_button{ GITHUB_NEW_VERSION_MORE_INFO, info.release_page_uri.ToString().c_str() } }, {},
std::move(toast_params)); { link_button{ GITHUB_NEW_VERSION_UPDATE_NOW, L"powertoys://download_and_install_update/" }, link_button{ GITHUB_NEW_VERSION_MORE_INFO, info.release_page_uri.ToString().c_str() } },
} std::move(toast_params));
}
void show_download_start(const updating::new_version_download_info& info)
{ void show_download_start(const updating::new_version_download_info& info)
::notifications::progress_bar_params progress_bar_params; {
std::wstring progress_title{ info.version_string }; remove_toasts(UPDATING_PROCESS_TOAST_TAG);
progress_title += L' ';
progress_title += localized_strings::DOWNLOAD_IN_PROGRESS; progress_bar_params progress_bar_params;
std::wstring progress_title{ info.version_string };
progress_bar_params.progress_title = progress_title; progress_title += L' ';
progress_bar_params.progress = .0f; progress_title += localized_strings::DOWNLOAD_IN_PROGRESS;
::notifications::toast_params toast_params{ UPDATE_NOTIFY_TOAST_TAG, false, std::move(progress_bar_params) };
::notifications::show_toast_with_activations(localized_strings::GITHUB_NEW_VERSION_DOWNLOAD_STARTED, progress_bar_params.progress_title = progress_title;
TOAST_TITLE, progress_bar_params.progress = .0f;
{}, toast_params toast_params{ UPDATING_PROCESS_TOAST_TAG, false, std::move(progress_bar_params) };
{}, show_toast_with_activations(localized_strings::GITHUB_NEW_VERSION_DOWNLOAD_STARTED,
std::move(toast_params)); TOAST_TITLE,
} {},
{},
void show_visit_github(const updating::new_version_download_info& info) std::move(toast_params));
{ }
::notifications::toast_params toast_params{ UPDATE_NOTIFY_TOAST_TAG, false };
std::wstring contents = GITHUB_NEW_VERSION_AVAILABLE_OFFER_VISIT; void show_visit_github(const updating::new_version_download_info& info)
contents += current_version_to_next_version(info); {
::notifications::show_toast_with_activations(std::move(contents), remove_toasts(UPDATING_PROCESS_TOAST_TAG);
TOAST_TITLE,
{}, toast_params toast_params{ UPDATING_PROCESS_TOAST_TAG, false };
{ ::notifications::link_button{ GITHUB_NEW_VERSION_VISIT, info.release_page_uri.ToString().c_str() } }, std::wstring contents = GITHUB_NEW_VERSION_AVAILABLE_OFFER_VISIT;
std::move(toast_params)); contents += current_version_to_next_version(info);
} show_toast_with_activations(std::move(contents),
TOAST_TITLE,
void show_install_error(const updating::new_version_download_info& info) {},
{ { link_button{ GITHUB_NEW_VERSION_VISIT, info.release_page_uri.ToString().c_str() } },
::notifications::toast_params toast_params{ UPDATE_NOTIFY_TOAST_TAG, false }; std::move(toast_params));
std::wstring contents = GITHUB_NEW_VERSION_DOWNLOAD_INSTALL_ERROR; }
contents += current_version_to_next_version(info);
::notifications::show_toast_with_activations(std::move(contents), void show_install_error(const updating::new_version_download_info& info)
TOAST_TITLE, {
{}, remove_toasts(UPDATING_PROCESS_TOAST_TAG);
{ ::notifications::link_button{ GITHUB_NEW_VERSION_VISIT, info.release_page_uri.ToString().c_str() } },
std::move(toast_params)); toast_params toast_params{ UPDATING_PROCESS_TOAST_TAG, false };
} std::wstring contents = GITHUB_NEW_VERSION_DOWNLOAD_INSTALL_ERROR;
contents += current_version_to_next_version(info);
void show_version_ready(const updating::new_version_download_info& info) show_toast_with_activations(std::move(contents),
{ TOAST_TITLE,
::notifications::toast_params toast_params{ UPDATE_READY_TOAST_TAG, false }; {},
std::wstring new_version_ready{ GITHUB_NEW_VERSION_READY_TO_INSTALL }; { link_button{ GITHUB_NEW_VERSION_VISIT, info.release_page_uri.ToString().c_str() } },
new_version_ready += current_version_to_next_version(info); std::move(toast_params));
}
::notifications::show_toast_with_activations(std::move(new_version_ready),
TOAST_TITLE, void show_version_ready(const updating::new_version_download_info& info)
{}, {
{ ::notifications::link_button{ GITHUB_NEW_VERSION_UPDATE_NOW, L"powertoys://update_now/" + info.installer_filename }, remove_toasts(UPDATING_PROCESS_TOAST_TAG);
::notifications::link_button{ GITHUB_NEW_VERSION_UPDATE_AFTER_RESTART, L"powertoys://schedule_update/" + info.installer_filename },
::notifications::snooze_button{ GITHUB_NEW_VERSION_SNOOZE_TITLE, { { GITHUB_NEW_VERSION_UPDATE_SNOOZE_1D, 24 * 60 }, { GITHUB_NEW_VERSION_UPDATE_SNOOZE_5D, 120 * 60 } } } }, toast_params toast_params{ UPDATING_PROCESS_TOAST_TAG, false };
std::move(toast_params)); std::wstring new_version_ready{ GITHUB_NEW_VERSION_READY_TO_INSTALL };
} new_version_ready += current_version_to_next_version(info);
void show_uninstallation_error() show_toast_with_activations(std::move(new_version_ready),
{ TOAST_TITLE,
::notifications::show_toast(localized_strings::UNINSTALLATION_UNKNOWN_ERROR, TOAST_TITLE); {},
} { link_button{ GITHUB_NEW_VERSION_UPDATE_NOW, L"powertoys://update_now/" + info.installer_filename },
link_button{ GITHUB_NEW_VERSION_UPDATE_AFTER_RESTART, L"powertoys://schedule_update/" + info.installer_filename },
void update_download_progress(const updating::new_version_download_info& info, float progress) snooze_button{ GITHUB_NEW_VERSION_SNOOZE_TITLE, { { GITHUB_NEW_VERSION_UPDATE_SNOOZE_1D, 24 * 60 }, { GITHUB_NEW_VERSION_UPDATE_SNOOZE_5D, 120 * 60 } } } },
{ std::move(toast_params));
::notifications::progress_bar_params progress_bar_params; }
std::wstring progress_title{ info.version_string }; void show_uninstallation_error()
progress_title += L' '; {
progress_title += progress < 1 ? localized_strings::DOWNLOAD_IN_PROGRESS : localized_strings::DOWNLOAD_COMPLETE; remove_toasts(UPDATING_PROCESS_TOAST_TAG);
progress_bar_params.progress_title = progress_title;
progress_bar_params.progress = progress; show_toast(localized_strings::UNINSTALLATION_UNKNOWN_ERROR, TOAST_TITLE);
::notifications::update_progress_bar_toast(UPDATE_NOTIFY_TOAST_TAG, progress_bar_params); }
}
} void update_download_progress(const updating::new_version_download_info& info, float progress)
{
progress_bar_params progress_bar_params;
std::wstring progress_title{ info.version_string };
progress_title += L' ';
progress_title += progress < 1 ? localized_strings::DOWNLOAD_IN_PROGRESS : localized_strings::DOWNLOAD_COMPLETE;
progress_bar_params.progress_title = progress_title;
progress_bar_params.progress = progress;
update_toast_progress_bar(UPDATING_PROCESS_TOAST_TAG, progress_bar_params);
}
}
} }

View File

@@ -1,19 +1,19 @@
#pragma once #pragma once
namespace updating namespace updating
{ {
struct new_version_download_info; struct new_version_download_info;
namespace notifications namespace notifications
{ {
void show_unavailable(); void show_unavailable();
void show_available(const updating::new_version_download_info& info); void show_available(const updating::new_version_download_info& info);
void show_download_start(const updating::new_version_download_info& info); void show_download_start(const updating::new_version_download_info& info);
void show_visit_github(const updating::new_version_download_info& info); void show_visit_github(const updating::new_version_download_info& info);
void show_install_error(const updating::new_version_download_info& info); void show_install_error(const updating::new_version_download_info& info);
void show_version_ready(const updating::new_version_download_info& info); void show_version_ready(const updating::new_version_download_info& info);
void show_uninstallation_error(); void show_uninstallation_error();
void update_download_progress(const updating::new_version_download_info& info, float progress); void update_download_progress(const updating::new_version_download_info& info, float progress);
} }
} }

View File

@@ -3,8 +3,8 @@
#include "version.h" #include "version.h"
#include "http_client.h" #include "http_client.h"
#include "notifications.h"
#include "updating.h" #include "updating.h"
#include "toast_notifications_helper.h"
#include <msi.h> #include <msi.h>
#include <common/common.h> #include <common/common.h>

View File

@@ -175,14 +175,14 @@
<ItemGroup> <ItemGroup>
<ClInclude Include="dotnet_installation.h" /> <ClInclude Include="dotnet_installation.h" />
<ClInclude Include="http_client.h" /> <ClInclude Include="http_client.h" />
<ClInclude Include="toast_notifications_helper.h" /> <ClInclude Include="notifications.h" />
<ClInclude Include="updating.h" /> <ClInclude Include="updating.h" />
<ClInclude Include="pch.h" /> <ClInclude Include="pch.h" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="dotnet_installation.cpp" /> <ClCompile Include="dotnet_installation.cpp" />
<ClCompile Include="http_client.cpp" /> <ClCompile Include="http_client.cpp" />
<ClCompile Include="toast_notifications_helper.cpp" /> <ClCompile Include="notifications.cpp" />
<ClCompile Include="updating.cpp" /> <ClCompile Include="updating.cpp" />
<ClCompile Include="pch.cpp"> <ClCompile Include="pch.cpp">
<PrecompiledHeader Condition="'$(CIBuild)'!='true'">Create</PrecompiledHeader> <PrecompiledHeader Condition="'$(CIBuild)'!='true'">Create</PrecompiledHeader>

View File

@@ -21,15 +21,15 @@
<ClInclude Include="updating.h"> <ClInclude Include="updating.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="toast_notifications_helper.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="http_client.h"> <ClInclude Include="http_client.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="dotnet_installation.h"> <ClInclude Include="dotnet_installation.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="notifications.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="pch.cpp"> <ClCompile Include="pch.cpp">
@@ -38,15 +38,15 @@
<ClCompile Include="updating.cpp"> <ClCompile Include="updating.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="toast_notifications_helper.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="http_client.cpp"> <ClCompile Include="http_client.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="dotnet_installation.cpp"> <ClCompile Include="dotnet_installation.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="notifications.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="packages.config" /> <None Include="packages.config" />

View File

@@ -301,8 +301,13 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
return 0; return 0;
} }
case SpecialMode::ReportSuccessfulUpdate: case SpecialMode::ReportSuccessfulUpdate:
notifications::show_toast(localized_strings::PT_UPDATE_MESSAGE_BOX_TEXT, L"PowerToys"); {
notifications::remove_toasts(notifications::UPDATING_PROCESS_TOAST_TAG);
notifications::show_toast(localized_strings::PT_UPDATE_MESSAGE_BOX_TEXT,
L"PowerToys",
notifications::toast_params{ notifications::UPDATING_PROCESS_TOAST_TAG });
break; break;
}
case SpecialMode::None: case SpecialMode::None:
// continue as usual // continue as usual