mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-04 05:53:43 +00:00 
			
		
		
		
	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:
		@@ -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();
 | 
			
		||||
 
 | 
			
		||||
@@ -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;
 | 
			
		||||
 
 | 
			
		||||
@@ -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,
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user