narrow: Fix incorrect values for use_first_unread_anchor.

Apparently, we were incorrectly passing through something related to
opts.use_initial_narrow_pointer as the value for `use_first_anchor`.

If you read the logic in narrow.js carefully,
use_initial_narrow_pointer was unconditionally false.

The correct value for this attribute is when we're trying to narrow to
the first unread message in a given context.  There are two things to
check:

* then_select_id is -1; i.e. we don't have a specific message ID we're
  trying to narrow around.
* select_first_unread is True, i.e. we're trying to narrow to the
  first unread message.

A bit more work should allow us to get rid of the second condition,
but I'm not quite confident enough to do that yet.
This commit is contained in:
Tim Abbott 2018-04-22 20:32:24 -07:00
parent 6d4855bd6a
commit 1d5204c82b
3 changed files with 3 additions and 3 deletions

View File

@ -165,7 +165,7 @@ function stub_message_list() {
assert.deepEqual(opts, {
cont: opts.cont,
then_select_id: selected_id,
use_initial_narrow_pointer: false,
use_first_unread_anchor: false,
});
};

View File

@ -137,7 +137,7 @@ exports.load_messages_for_narrow = function (opts) {
num_before: consts.narrow_before,
num_after: consts.narrow_after,
msg_list: msg_list,
use_first_unread_anchor: opts.use_initial_narrow_pointer,
use_first_unread_anchor: opts.use_first_unread_anchor,
cont: function (data) {
msg_list.fetch_status.finish_initial_narrow({
found_oldest: data.found_oldest,

View File

@ -215,7 +215,7 @@ exports.activate = function (raw_operators, opts) {
var defer_selecting_closest = message_list.narrowed.empty();
message_fetch.load_messages_for_narrow({
then_select_id: then_select_id,
use_initial_narrow_pointer: opts.use_initial_narrow_pointer,
use_first_unread_anchor: opts.select_first_unread && then_select_id === -1,
cont: function () {
if (defer_selecting_closest) {
maybe_select_closest();