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)
This commit is contained in:
Steve Howell
2013-06-14 10:46:37 -04:00
parent 3fd7c44331
commit acc338da0e
2 changed files with 17 additions and 32 deletions

View File

@@ -206,27 +206,23 @@ exports.received_messages = function (messages) {
var i; var i;
$.each(messages, function (index, message) { $.each(messages, function (index, message) {
if (message.sender_email !== page_params.email && // We send notifications for messages which the user has
narrow.message_in_home(message)) { // configured as notifiable, as long as they haven't been
// marked as read by process_visible_unread_messages
// We send notifications for messages which the user has // (which occurs if the message arrived onscreen while the
// configured as notifiable, as long as they haven't been // window had focus).
// marked as read by process_visible_unread_messages if (!(message_is_notifiable(message) && unread.message_unread(message))) {
// (which occurs if the message arrived onscreen while the return;
// window had focus). }
if (!(message_is_notifiable(message) && unread.message_unread(message))) { if (page_params.desktop_notifications_enabled &&
return; browser_desktop_notifications_on()) {
} process_desktop_notification(message);
if (page_params.desktop_notifications_enabled && }
browser_desktop_notifications_on()) { if (page_params.sounds_enabled && supports_sound) {
process_desktop_notification(message); if (window.bridge !== undefined) {
} window.bridge.bell();
if (page_params.sounds_enabled && supports_sound) { } else {
if (window.bridge !== undefined) { $("#notifications-area").find("audio")[0].play();
window.bridge.bell();
} else {
$("#notifications-area").find("audio")[0].play();
}
} }
} }
}); });

View File

@@ -35,20 +35,9 @@ function unread_hashkey(message) {
} }
exports.message_unread = function (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) { if (message === undefined) {
return false; 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 || return message.flags === undefined ||
message.flags.indexOf('read') === -1; message.flags.indexOf('read') === -1;
}; };