From acc338da0e5e1632b356fc9124d9c2353f81e65f Mon Sep 17 00:00:00 2001 From: Steve Howell Date: Fri, 14 Jun 2013 10:46:37 -0400 Subject: [PATCH] Remove redundant checks that messages were sent by user. When a user sends a message, it should be considered to be "read" by that same user, but all that logic is handled on the back end now, so we can remove some of the front end code related to saying that a message is unread. (imported from commit e4263f86c666882db42d7ae3d399196803d700cd) --- zephyr/static/js/notifications.js | 38 ++++++++++++++----------------- zephyr/static/js/unread.js | 11 --------- 2 files changed, 17 insertions(+), 32 deletions(-) diff --git a/zephyr/static/js/notifications.js b/zephyr/static/js/notifications.js index 10cc20c642..2aa88fcf68 100644 --- a/zephyr/static/js/notifications.js +++ b/zephyr/static/js/notifications.js @@ -206,27 +206,23 @@ exports.received_messages = function (messages) { var i; $.each(messages, function (index, message) { - if (message.sender_email !== page_params.email && - narrow.message_in_home(message)) { - - // We send notifications for messages which the user has - // configured as notifiable, as long as they haven't been - // marked as read by process_visible_unread_messages - // (which occurs if the message arrived onscreen while the - // window had focus). - if (!(message_is_notifiable(message) && unread.message_unread(message))) { - return; - } - if (page_params.desktop_notifications_enabled && - browser_desktop_notifications_on()) { - process_desktop_notification(message); - } - if (page_params.sounds_enabled && supports_sound) { - if (window.bridge !== undefined) { - window.bridge.bell(); - } else { - $("#notifications-area").find("audio")[0].play(); - } + // We send notifications for messages which the user has + // configured as notifiable, as long as they haven't been + // marked as read by process_visible_unread_messages + // (which occurs if the message arrived onscreen while the + // window had focus). + if (!(message_is_notifiable(message) && unread.message_unread(message))) { + return; + } + if (page_params.desktop_notifications_enabled && + browser_desktop_notifications_on()) { + process_desktop_notification(message); + } + if (page_params.sounds_enabled && supports_sound) { + if (window.bridge !== undefined) { + window.bridge.bell(); + } else { + $("#notifications-area").find("audio")[0].play(); } } }); diff --git a/zephyr/static/js/unread.js b/zephyr/static/js/unread.js index 04fe8fdd7e..fdfa6d4591 100644 --- a/zephyr/static/js/unread.js +++ b/zephyr/static/js/unread.js @@ -35,20 +35,9 @@ function unread_hashkey(message) { } exports.message_unread = function (message) { - // This is the only halfway interesting function in this module. - // Everything else is just slinging hashes around. - if (message === undefined) { return false; } - - var sent_by_human = ['website', 'iphone', 'android'] - .indexOf(message.client.toLowerCase()) !== -1; - - if (message.sender_email === page_params.email && sent_by_human) { - return false; - } - return message.flags === undefined || message.flags.indexOf('read') === -1; };