Properly handle a "top" update in an empty narrow.

Previously, it was impossible to narrow to a completely empty narrow.
Now it is possible, and the code needs to be tweaked in a few ways
not to break in this case.

(imported from commit e4dd4159ad52d003fc11d0b8b6531322c12a3de8)
This commit is contained in:
Waseem Daher 2012-11-20 22:32:39 -05:00
parent 161af7838f
commit 776a947f75
1 changed files with 4 additions and 4 deletions

View File

@ -271,9 +271,7 @@ function add_to_table(messages, table_name, filter_function, where, allow_collap
var current_group = []; var current_group = [];
var new_message_groups = []; var new_message_groups = [];
if (where === 'top' && narrow.allow_collapse()) { if (where === 'top' && narrow.allow_collapse() && message_groups[table_name].length > 0) {
// Assumption: We never get a 'top' update as the first update.
// Delete the current top message group, and add it back in with these // Delete the current top message group, and add it back in with these
// messages, in order to collapse properly. // messages, in order to collapse properly.
// //
@ -380,7 +378,9 @@ function add_to_table(messages, table_name, filter_function, where, allow_collap
row.find('.messagebox').addClass("next_is_same_sender"); row.find('.messagebox').addClass("next_is_same_sender");
} }
if (where === 'top') { 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); table.find('.ztable_layout_row').after(rendered_elems);
} else { } else {
table.append(rendered_elems); table.append(rendered_elems);