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.
exports.by_recipient = function () {
var original, message;
switch (message_dict[target_id].type) {
var message = message_dict[target_id];
switch (message.type) {
case 'personal':
// Narrow to personals with a specific user
original = message_dict[target_id];
do_narrow("Huddles with " + original.display_replay_to, function (other) {
do_narrow("Huddles with " + message.display_replay_to, function (other) {
return (other.type === 'personal') &&
(((other.display_recipient.email === original.display_recipient.email)
&& (other.sender_email === original.sender_email)) ||
((other.display_recipient.email === original.sender_email)
&& (other.sender_email === original.display_recipient.email)));
(((other.display_recipient.email === message.display_recipient.email)
&& (other.sender_email === message.sender_email)) ||
((other.display_recipient.email === message.sender_email)
&& (other.sender_email === message.display_recipient.email)));
});
break;
case 'huddle':
original = message_dict[target_id];
do_narrow("Huddles with " + original.display_reply_to, function (other) {
do_narrow("Huddles with " + message.display_reply_to, function (other) {
return (other.type === "personal" || other.type === "huddle")
&& other.reply_to === original.reply_to;
&& other.reply_to === message.reply_to;
});
break;
case 'stream':
original = message_dict[target_id];
message = original.display_recipient;
do_narrow(message, function (other) {
do_narrow(message.display_recipient, function (other) {
return (other.type === 'stream' &&
original.recipient_id === other.recipient_id);
message.recipient_id === other.recipient_id);
});
break;
}