From 5d7aa4fae7778bddc06a2afd1e4314c990aaa52d Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Wed, 26 Apr 2017 12:00:17 -0700 Subject: [PATCH] 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. --- static/js/hashchange.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/static/js/hashchange.js b/static/js/hashchange.js index dc2a65602b..0bb6dbdb7f 100644 --- a/static/js/hashchange.js +++ b/static/js/hashchange.js @@ -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; }