message_fetch: Deduplicate logic for start_newer_batch.

Like the other commits in this series, we were already doing this in
all of the callers of load_messages; this centralizes that logic in a
less ad-hoc feeling way.

We no longer use or need the start_initial_narrow function.
This commit is contained in:
Tim Abbott
2018-12-12 16:08:37 -08:00
parent 7febf724f3
commit ce187b0899
3 changed files with 9 additions and 17 deletions

View File

@@ -41,7 +41,7 @@ function blocked_history() {
run_test('basics', () => {
reset();
fetch_status.start_initial_narrow();
fetch_status.start_newer_batch();
fetch_status.start_older_batch();
blocked_newer();
@@ -64,7 +64,7 @@ run_test('basics', () => {
reset();
fetch_status.start_initial_narrow();
fetch_status.start_newer_batch();
fetch_status.start_older_batch();
blocked_newer();

View File

@@ -8,10 +8,6 @@ var FetchStatus = function () {
var found_newest = false;
var history_limited = false;
self.start_initial_narrow = function () {
loading_newer = true;
};
self.finish_initial_narrow = function (opts) {
loading_newer = false;
found_newest = opts.found_newest;

View File

@@ -119,6 +119,13 @@ exports.load_messages = function (opts) {
}
}
if (opts.num_after > 0) {
opts.msg_list.fetch_status.start_newer_batch();
if (opts.msg_list === home_msg_list) {
message_list.all.fetch_status.start_newer_batch();
}
}
data.client_gravatar = true;
channel.get({
@@ -159,8 +166,6 @@ exports.load_messages = function (opts) {
exports.load_messages_for_narrow = function (opts) {
var msg_list = message_list.narrowed;
msg_list.fetch_status.start_initial_narrow();
message_fetch.load_messages({
anchor: opts.then_select_id.toFixed(),
num_before: consts.narrow_before,
@@ -257,11 +262,6 @@ exports.maybe_load_newer_messages = function (opts) {
return;
}
msg_list.fetch_status.start_newer_batch();
if (msg_list === home_msg_list) {
message_list.all.fetch_status.start_newer_batch();
}
var anchor = exports.get_frontfill_anchor(msg_list).toFixed();
exports.load_messages({
@@ -326,8 +326,6 @@ exports.initialize = function () {
var messages = data.messages;
var latest_id = messages[messages.length - 1].id;
home_msg_list.fetch_status.start_newer_batch();
message_list.all.fetch_status.start_newer_batch();
exports.load_messages({
anchor: latest_id.toFixed(),
num_before: 0,
@@ -339,8 +337,6 @@ exports.initialize = function () {
}
if (page_params.have_initial_messages) {
home_msg_list.fetch_status.start_newer_batch();
message_list.all.fetch_status.start_newer_batch();
exports.load_messages({
anchor: page_params.pointer,
num_before: consts.num_before_pointer,