mirror of https://github.com/zulip/zulip.git
Refine offset logic for narrows.
We now only preserve the offset for the previous selection (pre-narrow) if that is still the id we want selected after calling maybe_add_local_messages. Right not this does not change any behavior, but upcoming changes to maybe_add_local_messages will change the selected id to the first unread message in certain circumstances, in which case preserving the offset will possibly be confusing, since you're not on the same message.
This commit is contained in:
parent
0dea143fcf
commit
08fd2027a1
|
@ -114,6 +114,19 @@ exports.activate = function (raw_operators, opts) {
|
|||
opts.then_select_id = parseInt(filter.operands("id")[0], 10);
|
||||
}
|
||||
|
||||
var offset_of_prev_selection = (function () {
|
||||
if (opts.then_select_offset !== undefined) {
|
||||
// If the caller passes in an explicit offset,
|
||||
// we don't need the offset of then_select_id;
|
||||
return;
|
||||
}
|
||||
|
||||
var row = current_msg_list.get_row(opts.then_select_id);
|
||||
if (row.length > 0) {
|
||||
return row.offset().top;
|
||||
}
|
||||
}());
|
||||
|
||||
var select_strategy;
|
||||
|
||||
if (opts.then_select_id >= 0) {
|
||||
|
@ -131,19 +144,6 @@ exports.activate = function (raw_operators, opts) {
|
|||
unread.messages_read_in_narrow = false;
|
||||
}
|
||||
|
||||
var then_select_offset;
|
||||
|
||||
if (opts.then_select_offset !== undefined) {
|
||||
then_select_offset = opts.then_select_offset;
|
||||
} else {
|
||||
if (select_strategy.flavor === 'exact') {
|
||||
var row = current_msg_list.get_row(select_strategy.msg_id);
|
||||
if (row.length > 0) {
|
||||
then_select_offset = row.offset().top;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// IMPORTANT! At this point we are heavily committed to
|
||||
// populating the new narrow, so we update our narrow_state.
|
||||
// From here on down, any calls to the narrow_state API will
|
||||
|
@ -189,6 +189,19 @@ exports.activate = function (raw_operators, opts) {
|
|||
});
|
||||
}
|
||||
|
||||
var then_select_offset = (function () {
|
||||
if (opts.then_select_offset !== undefined) {
|
||||
// We get passed in a offset for reloads.
|
||||
return opts.then_select_offset;
|
||||
}
|
||||
|
||||
if (select_strategy.flavor === 'exact') {
|
||||
if (select_strategy.msg_id === opts.then_select_id) {
|
||||
return offset_of_prev_selection;
|
||||
}
|
||||
}
|
||||
}());
|
||||
|
||||
var select_immediately = (select_strategy.flavor === 'exact');
|
||||
|
||||
(function fetch_messages() {
|
||||
|
|
Loading…
Reference in New Issue