From 07a156c40003f71aa4206a34c51d470d047a43a5 Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Thu, 24 Aug 2017 23:56:10 -0700 Subject: [PATCH] notifications: Fix desktop/sound notifications for @all. It appears that previously, these weren't being triggered. --- .../node_tests/message_list_view.js | 1 - static/js/notifications.js | 22 ++++++++----------- 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/frontend_tests/node_tests/message_list_view.js b/frontend_tests/node_tests/message_list_view.js index d5e7d03f41..b0d1c51eed 100644 --- a/frontend_tests/node_tests/message_list_view.js +++ b/frontend_tests/node_tests/message_list_view.js @@ -12,7 +12,6 @@ set_global('page_params', { set_global('home_msg_list', null); set_global('feature_flags', {twenty_four_hour_time: false}); set_global('people', {small_avatar_url: function () { return ''; }}); -set_global('notifications', {speaking_at_me: function () {}}); set_global('unread', {message_unread: function () {}}); // timerender calls setInterval when imported set_global('timerender', { diff --git a/static/js/notifications.js b/static/js/notifications.js index 4c78241e1f..203fd39143 100644 --- a/static/js/notifications.js +++ b/static/js/notifications.js @@ -388,14 +388,6 @@ exports.close_notification = function (message) { }); }; -exports.speaking_at_me = function (message) { - if (message === undefined) { - return false; - } - - return message.mentioned_me_directly; -}; - function message_is_notifiable(message) { // Independent of the user's notification settings, are there // properties of the message that unconditionally mean we @@ -411,15 +403,19 @@ function message_is_notifiable(message) { return false; } - // @- mentions take precedence over muted-ness. @all mentions - // are suppressed. - if (exports.speaking_at_me(message)) { + // @- mentions take precedence over muted-ness. Note + // that @all mentions are still suppressed by muting. + if (message.mentioned_me_directly) { return true; } + + // Messages to muted streams that don't mention us specifically + // are not notifiable. if ((message.type === "stream") && !stream_data.in_home_view(message.stream_id)) { return false; } + if ((message.type === "stream") && muting.is_topic_muted(message.stream, message.subject)) { return false; @@ -452,7 +448,7 @@ function should_send_desktop_notification(message) { return true; } - if (exports.speaking_at_me(message) && + if (message.mentioned && page_params.enable_desktop_notifications) { return true; } @@ -477,7 +473,7 @@ function should_send_audible_notification(message) { return true; } - if (exports.speaking_at_me(message) && page_params.enable_sounds) { + if (message.mentioned && page_params.enable_sounds) { return true; }