diff --git a/www/common/notifications.js b/www/common/notifications.js index 183915e6d..e1fb1c828 100644 --- a/www/common/notifications.js +++ b/www/common/notifications.js @@ -30,7 +30,15 @@ define([ var content = data.content; var msg = content.msg; $(el).find('.cp-notification-content p') - .html('Friend request accepted: '+msg.content.displayName+''); + .html(Messages._getKey('friendRequest_accepted', [msg.content.displayName]) + $(el).find('.cp-notification-dismiss').css('display', 'flex'); + }; + + handlers['DECLINE_FRIEND_REQUEST'] = function (common, data, el) { + var content = data.content; + var msg = content.msg; + $(el).find('.cp-notification-content p') + .html(Messages._getKey('friendRequest_declined', [msg.content.displayName]) $(el).find('.cp-notification-dismiss').css('display', 'flex'); }; diff --git a/www/common/outer/async-store.js b/www/common/outer/async-store.js index 0e0d6fe68..149ff2b87 100644 --- a/www/common/outer/async-store.js +++ b/www/common/outer/async-store.js @@ -945,6 +945,12 @@ define([ return; } // Otherwise, just remove the notification + store.mailbox.sendTo('DECLINE_FRIEND_REQUEST', {}, { + channel: msg.content.notifications, + curvePublic: msg.content.curvePublic + }, function (obj) { + cb(obj); + }); dismiss(); }; Store.sendFriendRequest = function (clientId, data, cb) { diff --git a/www/common/outer/mailbox-handlers.js b/www/common/outer/mailbox-handlers.js index c0b48f847..72a444a6d 100644 --- a/www/common/outer/mailbox-handlers.js +++ b/www/common/outer/mailbox-handlers.js @@ -15,6 +15,13 @@ define([ } cb(); }; + handlers['DECLINE_FRIEND_REQUEST'] = function (ctx, box, data, cb) { + // Our friend request was declined. + if (!ctx.store.proxy.friends_pending[data.msg.author]) { return void cb(true); } + delete ctx.store.proxy.friends_pending[data.msg.author]; + ctx.updateMetadata(); + cb(); + }; handlers['ACCEPT_FRIEND_REQUEST'] = function (ctx, box, data, cb) { // Our friend request was accepted. // Make sure we really sent it diff --git a/www/common/sframe-common-mailbox.js b/www/common/sframe-common-mailbox.js index bf0cee5cc..ad8524c21 100644 --- a/www/common/sframe-common-mailbox.js +++ b/www/common/sframe-common-mailbox.js @@ -8,7 +8,6 @@ define([ '/customize/messages.js' ], function ($, Util, UI, UIElements, Notifications, h, Messages) { var Mailbox = {}; - Messages = Messages; // XXX Mailbox.create = function (Common) { var mailbox = Common.mailbox; diff --git a/www/common/toolbar3.js b/www/common/toolbar3.js index 7aa4db367..7ab8d1a9b 100644 --- a/www/common/toolbar3.js +++ b/www/common/toolbar3.js @@ -959,7 +959,7 @@ MessengerUI, Messages) { }; var $newPadBlock = UIElements.createDropdown(dropdownConfig); var $button = $newPadBlock.find('button'); - $button.attr('title', Messages.notifications_title); + $button.attr('title', Messages.notifications_empty); $button.addClass('fa fa-bell-o'); var $n = $button.find('.cp-dropdown-button-title').hide(); var $empty = $(div).find('.cp-notifications-empty'); @@ -970,10 +970,12 @@ MessengerUI, Messages) { $button.removeClass('fa-bell-o').removeClass('fa-bell'); $n.removeClass('cp-notifications-small'); if (n === 0) { + $button.attr('title', Messages.notifications_empty); $empty.show(); $n.hide(); return void $button.addClass('fa-bell-o'); } + $button.attr('title', Messages.notifications_title); if (n > 99) { n = '99+'; $n.addClass('cp-notifications-small');