mirror of
https://github.com/zulip/zulip.git
synced 2025-11-04 22:13:26 +00:00
We recently added a feature to warn users that they
may need to scroll down to view messages that they
just sent, but it was broken due to various complexities
in the rendering code path.
Now we compute it a bit more rigorously.
It requires us to pass some info about rendering up
and down the stack, which is why it's kind of a long
commit, but the bulk of the logic is in these JS files:
* message_list_view.js
* notifications.js
I choose to pass structs around instead of booleans,
because I anticipate we may eventually add more metadata
about rendering to it, plus bools are just kinda brittle.
(The exceptions are that `_maybe_autoscroll`, which
is at the bottom of the stack, just passes back a simple
boolean, and `notify_local_mixes`, also at the bottom
of the stack, just accepts a simple boolean.)
This errs on the side of warning the user, even if the
new message is partially visible.
Fixes #11138
39 lines
943 B
JavaScript
39 lines
943 B
JavaScript
var message_util = (function () {
|
|
|
|
var exports = {};
|
|
|
|
exports.do_unread_count_updates = function do_unread_count_updates(messages) {
|
|
unread.process_loaded_messages(messages);
|
|
unread_ui.update_unread_counts();
|
|
resize.resize_page_components();
|
|
};
|
|
|
|
function add_messages(messages, msg_list, opts) {
|
|
if (!messages) {
|
|
return;
|
|
}
|
|
|
|
loading.destroy_indicator($('#page_loading_indicator'));
|
|
$('#first_run_message').remove();
|
|
|
|
var render_info = msg_list.add_messages(messages, opts);
|
|
|
|
return render_info;
|
|
}
|
|
|
|
exports.add_old_messages = function (messages, msg_list) {
|
|
return add_messages(messages, msg_list, {messages_are_new: false});
|
|
};
|
|
exports.add_new_messages = function (messages, msg_list) {
|
|
return add_messages(messages, msg_list, {messages_are_new: true});
|
|
};
|
|
|
|
|
|
return exports;
|
|
|
|
}());
|
|
if (typeof module !== 'undefined') {
|
|
module.exports = message_util;
|
|
}
|
|
window.message_util = message_util;
|