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:
parent
7ec813732a
commit
3ffa35dc8d
1 changed files with 7 additions and 2 deletions
|
@ -14,6 +14,7 @@
|
||||||
#include <wrl\wrappers\corewrappers.h>
|
#include <wrl\wrappers\corewrappers.h>
|
||||||
|
|
||||||
#include "base/environment.h"
|
#include "base/environment.h"
|
||||||
|
#include "base/hash/hash.h"
|
||||||
#include "base/logging.h"
|
#include "base/logging.h"
|
||||||
#include "base/strings/strcat.h"
|
#include "base/strings/strcat.h"
|
||||||
#include "base/strings/string_number_conversions.h"
|
#include "base/strings/string_number_conversions.h"
|
||||||
|
@ -71,6 +72,10 @@ void DebugLog(std::string_view log_msg) {
|
||||||
LOG(INFO) << log_msg;
|
LOG(INFO) << log_msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::wstring GetTag(const std::string& notification_id) {
|
||||||
|
return base::NumberToWString(base::Hash(notification_id));
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
// static
|
// static
|
||||||
|
@ -146,7 +151,7 @@ void WindowsToastNotification::Remove() {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ScopedHString group(kGroup);
|
ScopedHString group(kGroup);
|
||||||
ScopedHString tag(base::as_wcstr(base::UTF8ToUTF16(notification_id())));
|
ScopedHString tag(GetTag(notification_id()));
|
||||||
notification_history->RemoveGroupedTagWithId(tag, group, app_id);
|
notification_history->RemoveGroupedTagWithId(tag, group, app_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -199,7 +204,7 @@ HRESULT WindowsToastNotification::ShowInternal(
|
||||||
REPORT_AND_RETURN_IF_FAILED(toast2->put_Group(group),
|
REPORT_AND_RETURN_IF_FAILED(toast2->put_Group(group),
|
||||||
"WinAPI: Setting group failed");
|
"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),
|
REPORT_AND_RETURN_IF_FAILED(toast2->put_Tag(tag),
|
||||||
"WinAPI: Setting tag failed");
|
"WinAPI: Setting tag failed");
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue