message-edit: Always rerender home view after topic editing.

When editing a message changes the current narrow, we rerender the
narrowed view earlier in the function, so we don't need to do it here.
But we still need to rerender the home view, or the messages will be
displayed incorrectly once the user unnarrows!

Tweaked by tabbott for clarity and simplicity.

Fixes #2464.
This commit is contained in:
Bojidar Marinov 2016-12-22 15:17:56 +02:00 committed by Tim Abbott
parent 1046f16bb6
commit 8876179ef7
1 changed files with 8 additions and 7 deletions

View File

@ -302,14 +302,15 @@ exports.update_messages = function update_messages(events) {
alert_words.process_message(msg);
});
// If a topic was edited, we re-render the whole view to get any propagated edits
// to be updated
// If a topic was edited, we re-render the whole view to get any
// propagated edits to be updated (since the topic edits can have
// changed the correct grouping of messages).
if (topic_edited) {
if (!changed_narrow) {
home_msg_list.rerender();
if (current_msg_list === message_list.narrowed) {
message_list.narrowed.rerender();
}
home_msg_list.rerender();
// However, we don't need to rerender message_list.narrowed if
// we just changed the narrow earlier in this function.
if (!changed_narrow && current_msg_list === message_list.narrowed) {
message_list.narrowed.rerender();
}
} else {
home_msg_list.view.rerender_messages(msgs_to_rerender);