Extract compose.same_recipient_as_before()

(imported from commit 2ba8589127e3a0e86c00bb52a22be01bcad48a5d)
This commit is contained in:
Steve Howell
2013-08-12 14:19:02 -04:00
parent 6314089e26
commit 86b337ca75

View File

@@ -145,6 +145,15 @@ function fill_in_opts_from_current_narrowed_view(msg_type, opts) {
return opts; return opts;
} }
function same_recipient_as_before(msg_type, opts) {
return (compose.composing() === msg_type) &&
((msg_type === "stream" &&
opts.stream === compose.stream_name() &&
opts.subject === compose.subject()) ||
(msg_type === "private" &&
opts.private_message_recipient === compose.recipient()));
}
exports.start = function (msg_type, opts) { exports.start = function (msg_type, opts) {
if (reload.is_in_progress()) { if (reload.is_in_progress()) {
return; return;
@@ -156,12 +165,7 @@ exports.start = function (msg_type, opts) {
opts = fill_in_opts_from_current_narrowed_view(msg_type, opts); opts = fill_in_opts_from_current_narrowed_view(msg_type, opts);
if (!(compose.composing() === msg_type && if (!same_recipient_as_before(msg_type, opts)) {
((msg_type === "stream" &&
opts.stream === compose.stream_name() &&
opts.subject === compose.subject()) ||
(msg_type === "private" &&
opts.private_message_recipient === compose.recipient())))) {
// Clear the compose box if the existing message is to a different recipient // Clear the compose box if the existing message is to a different recipient
clear_box(); clear_box();
} }