From efda426b86e994035c61bb1cd00f06c60ac9af12 Mon Sep 17 00:00:00 2001 From: Jessica McKellar Date: Fri, 18 Oct 2013 13:28:29 -0400 Subject: [PATCH] notifications: split message_is_notifiable into multiple ifs for clarity. (imported from commit 33d1e2135a87192cc4d964db534b31ae9335595a) --- static/js/notifications.js | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/static/js/notifications.js b/static/js/notifications.js index 02edbe8162..98d92891ec 100644 --- a/static/js/notifications.js +++ b/static/js/notifications.js @@ -301,13 +301,31 @@ exports.speaking_at_me = function (message) { }; function message_is_notifiable(message) { - // based purely on message contents, can we notify the user about the message? - return (!message.sent_by_me && - (message.type === "private" || - exports.speaking_at_me(message) || - (message.type === "stream" && - subs.receives_notifications(message.stream)) || - alert_words.notifies(message))); + // Based purely on message contents, can we notify the user about + // the message? + + // First, does anything disqualify it from being notifiable? + if (message.sent_by_me) { + return false; + } + + // Then, do any properties make it notifiable? + if (message.type === "private") { + return true; + } + if (exports.speaking_at_me(message)) { + return true; + } + if ((message.type === "stream") && + subs.receives_notifications(message.stream)) { + return true; + } + if (alert_words.notifies(message)) { + return true; + } + + // Nope. + return false; } exports.received_messages = function (messages) {