Update notification PR as per feedback

This commit is contained in:
Samuel Attard 2017-06-28 17:00:19 +10:00
parent 7eb14243eb
commit 3774482859
4 changed files with 9 additions and 9 deletions

View file

@ -126,7 +126,7 @@ void Notification::SetHasReply(bool new_has_reply) {
} }
void Notification::SetActions( void Notification::SetActions(
const std::vector<brightray::NotificationAction> actions) { const std::vector<brightray::NotificationAction>& actions) {
actions_ = actions; actions_ = actions;
} }

View file

@ -60,7 +60,7 @@ class Notification : public mate::TrackableObject<Notification>,
void SetSilent(bool new_silent); void SetSilent(bool new_silent);
void SetReplyPlaceholder(const base::string16& new_reply_placeholder); void SetReplyPlaceholder(const base::string16& new_reply_placeholder);
void SetHasReply(bool new_has_reply); void SetHasReply(bool new_has_reply);
void SetActions(const std::vector<brightray::NotificationAction> actions); void SetActions(const std::vector<brightray::NotificationAction>& actions);
private: private:
base::string16 title_; base::string16 title_;

View file

@ -33,7 +33,7 @@ class CocoaNotification : public Notification {
private: private:
base::scoped_nsobject<NSUserNotification> notification_; base::scoped_nsobject<NSUserNotification> notification_;
int actionIndex_; int action_index_;
DISALLOW_COPY_AND_ASSIGN(CocoaNotification); DISALLOW_COPY_AND_ASSIGN(CocoaNotification);
}; };

View file

@ -44,14 +44,14 @@ void CocoaNotification::Show(const NotificationOptions& options) {
[notification_ setHasActionButton:false]; [notification_ setHasActionButton:false];
for (size_t i = 0; i < options.actions.size(); i++) { int i = 0;
NotificationAction action = options.actions[i]; for (const auto& action : options.actions) {
if (action.type == base::ASCIIToUTF16("button")) {
if (action.type == base::UTF8ToUTF16("button")) {
[notification_ setHasActionButton:true]; [notification_ setHasActionButton:true];
[notification_ setActionButtonTitle:base::SysUTF16ToNSString(action.text)]; [notification_ setActionButtonTitle:base::SysUTF16ToNSString(action.text)];
actionIndex_ = i; action_index_ = i;
} }
i++;
} }
if (options.has_reply) { if (options.has_reply) {
@ -82,7 +82,7 @@ void CocoaNotification::NotificationReplied(const std::string& reply) {
void CocoaNotification::NotificationButtonClicked() { void CocoaNotification::NotificationButtonClicked() {
if (delegate()) if (delegate())
delegate()->NotificationAction(actionIndex_); delegate()->NotificationAction(action_index_);
} }
} // namespace brightray } // namespace brightray