For topic changes, set the compose subject outside the loop.

If we get a topic change, we can change the subject outside the
loop, since we are passed in event.orig_subject.  Doing it inside
the loop was mostly harmless, since after you encountered the first
message with the old topic, the condition to change the subject
evaluated to false, but it was still technically O(N), and it was
kind of confusing.

This commit changes behavior in the edge case that you have the
compose box open for a changing subject, but you are in a narrow
that does not have any of the affected messages.  After this commit,
the topic in the compose box will still change, which I believe
is the correct behavior.

(imported from commit 2363e432ebe7ae8e07379324ee0bfb52051428e6)
This commit is contained in:
Steve Howell 2014-03-11 09:07:23 -04:00
parent dfc34eb074
commit ff44fb6fcf
1 changed files with 5 additions and 4 deletions

View File

@ -239,16 +239,17 @@ exports.update_messages = function update_messages(events) {
// event.message_ids. event.message_id is still the first message
// where the user initiated the edit.
topic_edited = true;
if (event.orig_subject === compose.subject()) {
compose.subject(event.subject);
}
_.each(event.message_ids, function (id) {
var msg = message_store.get(id);
if (msg === undefined) {
return;
}
if (msg.subject === compose.subject()) {
compose.subject(event.subject);
}
// Remove the recent subjects entry for the old subject;
// must be called before we update msg.subject
exports.process_message_for_recent_subjects(msg, true);