mirror of
https://github.com/zulip/zulip.git
synced 2025-10-30 11:33:51 +00:00
message_fetch: Deduplicate logic for start_older_batch.
We were doing this work individually in all the callers of load_messages; better is to just do it in one place.
This commit is contained in:
@@ -42,6 +42,7 @@ run_test('basics', () => {
|
|||||||
reset();
|
reset();
|
||||||
|
|
||||||
fetch_status.start_initial_narrow();
|
fetch_status.start_initial_narrow();
|
||||||
|
fetch_status.start_older_batch();
|
||||||
|
|
||||||
blocked_newer();
|
blocked_newer();
|
||||||
blocked_older();
|
blocked_older();
|
||||||
@@ -64,6 +65,7 @@ run_test('basics', () => {
|
|||||||
reset();
|
reset();
|
||||||
|
|
||||||
fetch_status.start_initial_narrow();
|
fetch_status.start_initial_narrow();
|
||||||
|
fetch_status.start_older_batch();
|
||||||
|
|
||||||
blocked_newer();
|
blocked_newer();
|
||||||
blocked_older();
|
blocked_older();
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ var FetchStatus = function () {
|
|||||||
|
|
||||||
self.start_initial_narrow = function () {
|
self.start_initial_narrow = function () {
|
||||||
loading_newer = true;
|
loading_newer = true;
|
||||||
loading_older = true;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
self.finish_initial_narrow = function (opts) {
|
self.finish_initial_narrow = function (opts) {
|
||||||
|
|||||||
@@ -112,6 +112,13 @@ exports.load_messages = function (opts) {
|
|||||||
data.use_first_unread_anchor = true;
|
data.use_first_unread_anchor = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (opts.num_before > 0) {
|
||||||
|
opts.msg_list.fetch_status.start_older_batch();
|
||||||
|
if (opts.msg_list === home_msg_list) {
|
||||||
|
message_list.all.fetch_status.start_older_batch();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
data.client_gravatar = true;
|
data.client_gravatar = true;
|
||||||
|
|
||||||
channel.get({
|
channel.get({
|
||||||
@@ -223,12 +230,6 @@ exports.maybe_load_older_messages = function (opts) {
|
|||||||
|
|
||||||
exports.do_backfill = function (opts) {
|
exports.do_backfill = function (opts) {
|
||||||
var msg_list = opts.msg_list;
|
var msg_list = opts.msg_list;
|
||||||
|
|
||||||
msg_list.fetch_status.start_older_batch();
|
|
||||||
if (msg_list === home_msg_list) {
|
|
||||||
message_list.all.fetch_status.start_older_batch();
|
|
||||||
}
|
|
||||||
|
|
||||||
var anchor = exports.get_backfill_anchor(msg_list).toFixed();
|
var anchor = exports.get_backfill_anchor(msg_list).toFixed();
|
||||||
|
|
||||||
exports.load_messages({
|
exports.load_messages({
|
||||||
@@ -340,8 +341,6 @@ exports.initialize = function () {
|
|||||||
if (page_params.have_initial_messages) {
|
if (page_params.have_initial_messages) {
|
||||||
home_msg_list.fetch_status.start_newer_batch();
|
home_msg_list.fetch_status.start_newer_batch();
|
||||||
message_list.all.fetch_status.start_newer_batch();
|
message_list.all.fetch_status.start_newer_batch();
|
||||||
home_msg_list.fetch_status.start_older_batch();
|
|
||||||
message_list.all.fetch_status.start_older_batch();
|
|
||||||
exports.load_messages({
|
exports.load_messages({
|
||||||
anchor: page_params.pointer,
|
anchor: page_params.pointer,
|
||||||
num_before: consts.num_before_pointer,
|
num_before: consts.num_before_pointer,
|
||||||
|
|||||||
Reference in New Issue
Block a user