Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

message view: Show home view bottom loading indicators.

Ryan Rehmane0b1fdb81c34
diff --git a/frontend_tests/node_tests/fetch_status.js b/frontend_tests/node_tests/fetch_status.js
index 581356b6cfd..2a98600e596 100644
--- a/frontend_tests/node_tests/fetch_status.js
+++ b/frontend_tests/node_tests/fetch_status.js
@@ -1,4 +1,8 @@
const FetchStatus = zrequire('fetch_status');
+set_global('message_scroll', {
+ hide_loading_newer: () => {},
+ show_loading_newer: () => {},
+});
let fetch_status = FetchStatus();
@@ -49,7 +53,7 @@ function blocked_history() {
run_test('basics', () => {
reset();
- fetch_status.start_newer_batch();
+ fetch_status.start_newer_batch({ update_loading_indicator: false });
fetch_status.start_older_batch();
blocked_newer();
@@ -59,6 +63,7 @@ run_test('basics', () => {
has_not_found_newest();
let data = {
+ update_loading_indicator: false,
found_oldest: true,
found_newest: true,
history_limited: true,
@@ -74,7 +79,7 @@ run_test('basics', () => {
reset();
- fetch_status.start_newer_batch();
+ fetch_status.start_newer_batch({ update_loading_indicator: true });
fetch_status.start_older_batch();
blocked_newer();
@@ -82,6 +87,7 @@ run_test('basics', () => {
can_load_history();
data = {
+ update_loading_indicator: false,
found_oldest: false,
found_newest: false,
history_limited: false,
@@ -132,24 +138,26 @@ run_test('basics', () => {
can_load_older();
can_load_newer();
- fetch_status.start_newer_batch();
+ fetch_status.start_newer_batch({ update_loading_indicator: false });
can_load_older();
blocked_newer();
fetch_status.finish_newer_batch({
+ update_loading_indicator: true,
found_newest: false,
});
can_load_older();
can_load_newer();
- fetch_status.start_newer_batch();
+ fetch_status.start_newer_batch({ update_loading_indicator: true });
can_load_older();
blocked_newer();
fetch_status.finish_newer_batch({
+ update_loading_indicator: true,
found_newest: true,
});
diff --git a/frontend_tests/node_tests/narrow_activate.js b/frontend_tests/node_tests/narrow_activate.js
index 062aefd3bae..f6cbd750194 100644
--- a/frontend_tests/node_tests/narrow_activate.js
+++ b/frontend_tests/node_tests/narrow_activate.js
@@ -203,8 +203,8 @@ run_test('basics', () => {
'notifications.redraw_title',
'notifications.hide_history_limit_notice',
'notifications.hide_end_of_results_notice',
- 'ui_util.change_tab_to',
'message_scroll.hide_indicators',
+ 'ui_util.change_tab_to',
'unread_ops.process_visible',
'hashchange.save_narrow',
'compose.update_closed_compose_buttons_for_stream',
diff --git a/static/js/fetch_status.js b/static/js/fetch_status.js
index 830d1f24a05..34b2e2763cf 100644
--- a/static/js/fetch_status.js
+++ b/static/js/fetch_status.js
@@ -30,13 +30,19 @@ const FetchStatus = function () {
return history_limited;
};
- self.start_newer_batch = function () {
+ self.start_newer_batch = function (opts) {
loading_newer = true;
+ if (opts.update_loading_indicator) {
+ message_scroll.show_loading_newer();
+ }
};
self.finish_newer_batch = function (opts) {
loading_newer = false;
found_newest = opts.found_newest;
+ if (opts.update_loading_indicator) {
+ message_scroll.hide_loading_newer();
+ }
};
self.can_load_newer_messages = function () {
diff --git a/static/js/message_fetch.js b/static/js/message_fetch.js
index 6522d19a71d..2355e6e995d 100644
--- a/static/js/message_fetch.js
+++ b/static/js/message_fetch.js
@@ -61,12 +61,17 @@ function process_result(data, opts) {
}
function get_messages_success(data, opts) {
+ const update_loading_indicator = opts.msg_list === current_msg_list;
if (opts.num_before > 0) {
opts.msg_list.data.fetch_status.finish_older_batch({
found_oldest: data.found_oldest,
history_limited: data.history_limited,
});
if (opts.msg_list === home_msg_list) {
+ // When we update home_msg_list, we need to also update
+ // the fetch_status data structure for message_list.all,
+ // which is never rendered (and just used for
+ // prepopulating narrowed views).
message_list.all.data.fetch_status.finish_older_batch({
found_oldest: data.found_oldest,
history_limited: data.history_limited,
@@ -77,10 +82,16 @@ function get_messages_success(data, opts) {
if (opts.num_after > 0) {
opts.msg_list.data.fetch_status.finish_newer_batch({
+ update_loading_indicator: update_loading_indicator,
found_newest: data.found_newest,
});
if (opts.msg_list === home_msg_list) {
+ // When we update home_msg_list, we need to also update
+ // the fetch_status data structure for message_list.all,
+ // which is never rendered (and just used for
+ // prepopulating narrowed views).
message_list.all.data.fetch_status.finish_newer_batch({
+ update_loading_indicator: false,
found_newest: data.found_newest,
});
}
@@ -161,6 +172,7 @@ exports.load_messages = function (opts) {
data.narrow = JSON.stringify(page_params.narrow);
}
+ const update_loading_indicator = opts.msg_list === current_msg_list;
if (opts.num_before > 0) {
opts.msg_list.data.fetch_status.start_older_batch();
if (opts.msg_list === home_msg_list) {
@@ -169,9 +181,13 @@ exports.load_messages = function (opts) {
}
if (opts.num_after > 0) {
- opts.msg_list.data.fetch_status.start_newer_batch();
+ opts.msg_list.data.fetch_status.start_newer_batch({
+ update_loading_indicator: update_loading_indicator,
+ });
if (opts.msg_list === home_msg_list) {
- message_list.all.data.fetch_status.start_newer_batch();
+ message_list.all.data.fetch_status.start_newer_batch({
+ update_loading_indicator: update_loading_indicator,
+ });
}
}
@@ -307,7 +323,6 @@ exports.maybe_load_newer_messages = function (opts) {
return;
}
- opts.show_loading();
const anchor = exports.get_frontfill_anchor(msg_list).toFixed();
exports.load_messages({
@@ -315,9 +330,6 @@ exports.maybe_load_newer_messages = function (opts) {
num_before: 0,
num_after: consts.forward_batch_size,
msg_list: msg_list,
- cont: function () {
- opts.hide_loading();
- },
});
};
diff --git a/static/js/message_scroll.js b/static/js/message_scroll.js
index 703df3769a0..50f83156d3e 100644
--- a/static/js/message_scroll.js
+++ b/static/js/message_scroll.js
@@ -71,8 +71,6 @@ exports.scroll_finished = function () {
if (message_viewport.at_bottom()) {
message_fetch.maybe_load_newer_messages({
msg_list: current_msg_list,
- show_loading: exports.show_loading_newer,
- hide_loading: exports.hide_loading_newer,
});
}
diff --git a/static/js/narrow.js b/static/js/narrow.js
index 1df6402dda9..ecc6181c078 100644
--- a/static/js/narrow.js
+++ b/static/js/narrow.js
@@ -150,6 +150,7 @@ exports.activate = function (raw_operators, opts) {
update_narrow_title(filter);
notifications.hide_history_limit_notice();
notifications.hide_end_of_results_notice();
+ message_scroll.hide_indicators();
blueslip.debug("Narrowed", {operators: operators.map(e => e.operator),
trigger: opts ? opts.trigger : undefined,
@@ -293,7 +294,6 @@ exports.activate = function (raw_operators, opts) {
});
}());
- message_scroll.hide_indicators();
if (select_immediately) {
exports.update_selection({
id_info: id_info,