From 1cf2d993a6bbe104ded3ab9802e69a09fd21413a Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Wed, 29 May 2013 18:10:10 -0400 Subject: [PATCH] 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) --- zephyr/static/js/ui.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/zephyr/static/js/ui.js b/zephyr/static/js/ui.js index d1167c416e..38dd1c6a6d 100644 --- a/zephyr/static/js/ui.js +++ b/zephyr/static/js/ui.js @@ -1191,6 +1191,10 @@ $(function () { if (current_msg_list !== event.msg_list) { 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); $('.selected_message').removeClass('selected_message'); row.addClass('selected_message');