Fix un-narrowing while the home view messages are still loading.

The bug we experienced here was that if you loaded the page in a
narrowed view, and then un-narrowed before the first block of messages
for the home view arrived via load_old_messages, then
narrow.deactivate() would re-select ID -1 in home_msg_list.  This ends
up calling recenter_view() on the message, which in turn tries to
access the message with message id -1, which fails.

We do sometimes re-select a message ID in order to recenter the view
properly when we prepend messages to a message list, so we can't make
this always a nop; instead we add a check for id -1 in the
message_selected.zephyr event handler.

(imported from commit 66f84a586e59d99aaf0e4ba2cda9fe597b033145)
This commit is contained in:
Tim Abbott
2013-05-29 18:10:10 -04:00
parent b34fc4d78f
commit 1cf2d993a6

View File

@@ -1191,6 +1191,10 @@ $(function () {
if (current_msg_list !== event.msg_list) { if (current_msg_list !== event.msg_list) {
return; return;
} }
if (event.id === -1) {
// If the message list is empty, don't do anything
return;
}
var row = rows.get(event.id, event.msg_list.table_name); var row = rows.get(event.id, event.msg_list.table_name);
$('.selected_message').removeClass('selected_message'); $('.selected_message').removeClass('selected_message');
row.addClass('selected_message'); row.addClass('selected_message');