diff --git a/frontend_tests/node_tests/fetch_status.js b/frontend_tests/node_tests/fetch_status.js index 0168a7897a..2281e9f748 100644 --- a/frontend_tests/node_tests/fetch_status.js +++ b/frontend_tests/node_tests/fetch_status.js @@ -54,7 +54,7 @@ run_test('basics', () => { found_newest: true, history_limited: true, }; - fetch_status.finish_initial_narrow(data); + fetch_status.finish_newer_batch(data); fetch_status.finish_older_batch(data); has_found_newest(); @@ -76,7 +76,7 @@ run_test('basics', () => { found_newest: false, history_limited: false, }; - fetch_status.finish_initial_narrow(data); + fetch_status.finish_newer_batch(data); fetch_status.finish_older_batch(data); can_load_older(); diff --git a/static/js/fetch_status.js b/static/js/fetch_status.js index b2f1bbaa96..7546c25740 100644 --- a/static/js/fetch_status.js +++ b/static/js/fetch_status.js @@ -8,11 +8,6 @@ var FetchStatus = function () { var found_newest = false; var history_limited = false; - self.finish_initial_narrow = function (opts) { - loading_newer = false; - found_newest = opts.found_newest; - }; - self.start_older_batch = function () { loading_older = true; }; diff --git a/static/js/message_fetch.js b/static/js/message_fetch.js index e32e83b91c..cb35ee8294 100644 --- a/static/js/message_fetch.js +++ b/static/js/message_fetch.js @@ -74,6 +74,17 @@ function get_messages_success(data, opts) { } } + if (opts.num_after > 0) { + opts.msg_list.fetch_status.finish_newer_batch({ + found_newest: data.found_newest, + }); + if (opts.msg_list === home_msg_list) { + message_list.all.fetch_status.finish_newer_batch({ + found_newest: data.found_newest, + }); + } + } + if (opts.msg_list.narrowed && opts.msg_list !== current_msg_list) { // We unnarrowed before receiving new messages so // don't bother processing the newly arrived messages. @@ -172,11 +183,7 @@ exports.load_messages_for_narrow = function (opts) { num_after: consts.narrow_after, msg_list: msg_list, use_first_unread_anchor: opts.use_first_unread_anchor, - cont: function (data) { - msg_list.fetch_status.finish_initial_narrow({ - found_oldest: data.found_oldest, - found_newest: data.found_newest, - }); + cont: function () { message_scroll.hide_indicators(); opts.cont(); }, @@ -269,16 +276,6 @@ exports.maybe_load_newer_messages = function (opts) { num_before: 0, num_after: consts.forward_batch_size, msg_list: msg_list, - cont: function (data) { - msg_list.fetch_status.finish_newer_batch({ - found_newest: data.found_newest, - }); - if (msg_list === home_msg_list) { - message_list.all.fetch_status.finish_newer_batch({ - found_newest: data.found_newest, - }); - } - }, }); }; @@ -307,14 +304,6 @@ exports.initialize = function () { target_scroll_offset: page_params.initial_offset}); } - home_msg_list.fetch_status.finish_newer_batch({ - found_newest: data.found_newest, - }); - - message_list.all.fetch_status.finish_newer_batch({ - found_newest: data.found_newest, - }); - if (data.found_newest) { server_events.home_view_loaded(); exports.start_backfilling_messages();