🏁 Notify only when enabled

- Previously, we'd attempt to create a notification no matter what the
  user's configuration was. Microsoft advises against that, because it
  can create race conditions if notifications are disabled.
- This fixes the issue.

Closes https://github.com/atom/electron/issues/4681
This commit is contained in:
Felix Rieseberg 2016-03-15 17:10:24 -07:00
parent bbfa5835e7
commit b68be5c583

View file

@ -90,6 +90,15 @@ void WindowsToastNotification::Show(
auto presenter_win = static_cast<NotificationPresenterWin*>(presenter()); auto presenter_win = static_cast<NotificationPresenterWin*>(presenter());
std::wstring icon_path = presenter_win->SaveIconToFilesystem(icon, icon_url); std::wstring icon_path = presenter_win->SaveIconToFilesystem(icon, icon_url);
// Ask Windows for the current notification settings
// If not allowed, we return here (0 = enabled)
ABI::Windows::UI::Notifications::NotificationSetting setting;
toast_notifier_->get_Setting(&setting);
if (setting != 0) {
NotificationFailed();
return;
}
ComPtr<IXmlDocument> toast_xml; ComPtr<IXmlDocument> toast_xml;
if(FAILED(GetToastXml(toast_manager_.Get(), title, msg, icon_path, silent, &toast_xml))) { if(FAILED(GetToastXml(toast_manager_.Get(), title, msg, icon_path, silent, &toast_xml))) {
NotificationFailed(); NotificationFailed();