hashchange: Fix buggy narrowing to wrong message.

Due to a past refactoring, the from_reload argument to do_hashchange
changed from having true/undefined as the possible values to
true/false instead.  The check that sets the from_reload and
first_unread_from_server narrow options was thus incorreclty treating
from_reload of false the same as a from_reload of undefined.

As a result, if the browser had been loaded with a
page_params.initial_narrow_pointer (aka via the background reload code
path), then for the duration of that browser session, every time one
narrowed via a hashchange rather than an explicit click handler (which
apparently includes clicking on a PM thread in the left sidebar), we'd
end up narrowing with a then_select_id of the that initial narrow
pointer, not the correct first unread message.

The fix is simply changing the check for truthiness, not undefined, in
do_hashchange.
This commit is contained in:
Tim Abbott 2017-04-26 12:00:17 -07:00
parent f4a9651346
commit 5d7aa4fae7

View File

@ -135,7 +135,7 @@ function do_hashchange(from_reload) {
change_hash: false, // already set
trigger: 'hash change',
};
if (from_reload !== undefined && page_params.initial_narrow_pointer !== undefined) {
if (from_reload && page_params.initial_narrow_pointer !== undefined) {
narrow_opts.from_reload = true;
narrow_opts.first_unread_from_server = true;
}