зеркало из https://github.com/electron/electron.git
fix: `Notification` with reply obscuring first action on macOS (#37381)
fix: Notification with reply obscuring first action
This commit is contained in:
Родитель
1f390119fe
Коммит
8fb0f43030
|
@ -58,7 +58,11 @@ void CocoaNotification::Show(const NotificationOptions& options) {
|
|||
[notification_ setSoundName:base::SysUTF16ToNSString(options.sound)];
|
||||
}
|
||||
|
||||
[notification_ setHasActionButton:false];
|
||||
if (options.has_reply) {
|
||||
[notification_ setHasReplyButton:true];
|
||||
[notification_ setResponsePlaceholder:base::SysUTF16ToNSString(
|
||||
options.reply_placeholder)];
|
||||
}
|
||||
|
||||
int i = 0;
|
||||
action_index_ = UINT_MAX;
|
||||
|
@ -66,7 +70,10 @@ void CocoaNotification::Show(const NotificationOptions& options) {
|
|||
[[[NSMutableArray alloc] init] autorelease];
|
||||
for (const auto& action : options.actions) {
|
||||
if (action.type == u"button") {
|
||||
if (action_index_ == UINT_MAX) {
|
||||
// If the notification has both a reply and actions,
|
||||
// the reply takes precedence and the actions all
|
||||
// become additional actions.
|
||||
if (!options.has_reply && action_index_ == UINT_MAX) {
|
||||
// First button observed is the displayed action
|
||||
[notification_ setHasActionButton:true];
|
||||
[notification_
|
||||
|
@ -86,16 +93,11 @@ void CocoaNotification::Show(const NotificationOptions& options) {
|
|||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
if ([additionalActions count] > 0) {
|
||||
[notification_ setAdditionalActions:additionalActions];
|
||||
}
|
||||
|
||||
if (options.has_reply) {
|
||||
[notification_ setResponsePlaceholder:base::SysUTF16ToNSString(
|
||||
options.reply_placeholder)];
|
||||
[notification_ setHasReplyButton:true];
|
||||
}
|
||||
|
||||
if (!options.close_button_text.empty()) {
|
||||
[notification_ setOtherButtonTitle:base::SysUTF16ToNSString(
|
||||
options.close_button_text)];
|
||||
|
|
Загрузка…
Ссылка в новой задаче