Fix collapse issue introduced by ca50035 while keeping the effect of its fix.

That commit intended to fix a bug where it jumps to the wrong scroll position
(offset by the difference in height from uncollapsed to collapsed) if you load
collapsed messages at the top, either by scrolling up or when it automatically
fetches more 10s after page load, because before, it updated the scroll
position before processing collapsing, which changes the height of messages.

Updating collapsing needs to happen before the viewport is adjusted, but also
needs to happen after the new messages get appended/prepended to the document
because they need to be attached to the document for getClientBoundingRect to
work.

(imported from commit 44d6a6135524e658084ffcf7d880ba898b577e6d)
This commit is contained in:
Kevin Mehall 2013-07-24 10:39:27 -04:00
parent f647596cbb
commit dfda1d3137
1 changed files with 9 additions and 9 deletions

View File

@ -434,19 +434,10 @@ MessageList.prototype = {
}
}
$.each(rendered_elems, ui.process_condensing);
if (where === 'top' && table.find('.ztable_layout_row').length > 0) {
// If we have a totally empty narrow, there may not
// be a .ztable_layout_row.
table.find('.ztable_layout_row').after(rendered_elems);
if (this === current_msg_list && orig_scrolltop_offset !== undefined) {
// Restore the selected row to its original position in
// relation to the top of the window
viewport.scrollTop(this.selected_row().offset().top - orig_scrolltop_offset);
this.select_id(this._selected_id, {from_rendering: true});
}
} else {
table.append(rendered_elems);
@ -477,6 +468,15 @@ MessageList.prototype = {
message_edit.maybe_show_edit(row, id);
});
$.each(rendered_elems, ui.process_condensing);
if (where === 'top' && this === current_msg_list && orig_scrolltop_offset !== undefined) {
// Restore the selected row to its original position in
// relation to the top of the window
viewport.scrollTop(this.selected_row().offset().top - orig_scrolltop_offset);
this.select_id(this._selected_id, {from_rendering: true});
}
// Re-add the fading of messages that is lost when we re-render.
compose.update_faded_messages();