Clean up narrow.by_recipient

(imported from commit ca6665f29847077d6038d3f48821c4be02e95ff1)
This commit is contained in:
Keegan McAllister 2012-10-19 13:00:46 -04:00
parent 390c9a26c1
commit 5d0fdd1958
1 changed files with 11 additions and 16 deletions

View File

@ -81,35 +81,30 @@ exports.by_subject = function () {
// Called for the 'narrow by stream' hotkey. // Called for the 'narrow by stream' hotkey.
exports.by_recipient = function () { exports.by_recipient = function () {
var original, message; var message = message_dict[target_id];
switch (message_dict[target_id].type) { switch (message.type) {
case 'personal': case 'personal':
// Narrow to personals with a specific user // Narrow to personals with a specific user
original = message_dict[target_id]; do_narrow("Huddles with " + message.display_replay_to, function (other) {
do_narrow("Huddles with " + original.display_replay_to, function (other) {
return (other.type === 'personal') && return (other.type === 'personal') &&
(((other.display_recipient.email === original.display_recipient.email) (((other.display_recipient.email === message.display_recipient.email)
&& (other.sender_email === original.sender_email)) || && (other.sender_email === message.sender_email)) ||
((other.display_recipient.email === original.sender_email) ((other.display_recipient.email === message.sender_email)
&& (other.sender_email === original.display_recipient.email))); && (other.sender_email === message.display_recipient.email)));
}); });
break; break;
case 'huddle': case 'huddle':
original = message_dict[target_id]; do_narrow("Huddles with " + message.display_reply_to, function (other) {
do_narrow("Huddles with " + original.display_reply_to, function (other) {
return (other.type === "personal" || other.type === "huddle") return (other.type === "personal" || other.type === "huddle")
&& other.reply_to === original.reply_to; && other.reply_to === message.reply_to;
}); });
break; break;
case 'stream': case 'stream':
original = message_dict[target_id]; do_narrow(message.display_recipient, function (other) {
message = original.display_recipient;
do_narrow(message, function (other) {
return (other.type === 'stream' && return (other.type === 'stream' &&
original.recipient_id === other.recipient_id); message.recipient_id === other.recipient_id);
}); });
break; break;
} }