зеркало из https://github.com/electron/electron.git
fix: calculate a hash for the Tag property of ToastNotification. (#42239)
* fix: calculate a hash for the Tag property of ToastNotification. * fix: calculate a hash for the Tag property of ToastNotification. --------- Co-authored-by: bill.shen <shenyb32768@gmail.com>
This commit is contained in:
Родитель
7ec813732a
Коммит
3ffa35dc8d
|
@ -14,6 +14,7 @@
|
|||
#include <wrl\wrappers\corewrappers.h>
|
||||
|
||||
#include "base/environment.h"
|
||||
#include "base/hash/hash.h"
|
||||
#include "base/logging.h"
|
||||
#include "base/strings/strcat.h"
|
||||
#include "base/strings/string_number_conversions.h"
|
||||
|
@ -71,6 +72,10 @@ void DebugLog(std::string_view log_msg) {
|
|||
LOG(INFO) << log_msg;
|
||||
}
|
||||
|
||||
std::wstring GetTag(const std::string& notification_id) {
|
||||
return base::NumberToWString(base::Hash(notification_id));
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
// static
|
||||
|
@ -146,7 +151,7 @@ void WindowsToastNotification::Remove() {
|
|||
return;
|
||||
|
||||
ScopedHString group(kGroup);
|
||||
ScopedHString tag(base::as_wcstr(base::UTF8ToUTF16(notification_id())));
|
||||
ScopedHString tag(GetTag(notification_id()));
|
||||
notification_history->RemoveGroupedTagWithId(tag, group, app_id);
|
||||
}
|
||||
|
||||
|
@ -199,7 +204,7 @@ HRESULT WindowsToastNotification::ShowInternal(
|
|||
REPORT_AND_RETURN_IF_FAILED(toast2->put_Group(group),
|
||||
"WinAPI: Setting group failed");
|
||||
|
||||
ScopedHString tag(base::as_wcstr(base::UTF8ToUTF16(notification_id())));
|
||||
ScopedHString tag(GetTag(notification_id()));
|
||||
REPORT_AND_RETURN_IF_FAILED(toast2->put_Tag(tag),
|
||||
"WinAPI: Setting tag failed");
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче